This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Parsing using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Parsing using Java" Watch "Parsing using Java" New topic
Author

Parsing using Java

Jack Parrot
Greenhorn

Joined: Oct 29, 2009
Posts: 1
I have a string s that literally contains "This\tis\"my\"\tstring" that litterally contains all those characters including \t and \".

I am trying to figure out how to parse that string with the \t and \" and resolve them to their true meaning and then rebuild the string s so that it outputs:
This [tab] is[tab] "My"[tab] string.

[tab] cannot be displayed here but I am sure everyone knows that a tab is set of fixed number of spaces.

Can someone give me hint so i can have a direction to figure it out??? Thank you.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19728
    
  10

No, not everyone knows that a tab is set of fixed number of spaces. Because it isn't. It's just a character. And often displaying it results in displaying a number of spaces instead. But not a fixed number of spaces. A lot of output displays have tab stops at (for example) every 4 positions, so a tab character will be represented by between 1 and 4 spaces. At other times displaying a tab character has no effect at all, as for example in HTML.

But anyway that's all irrelevant if your question is how to replace the pair of characters (backslash, 't') by a single tab character. You do that like this:

That's a hint, so I will leave the other half for you.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Parsing using Java
 
jQuery in Action, 3rd edition