This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
Bartender

Joined: Oct 14, 2005
Posts: 18121
    
    8

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing using Java
 
Similar Threads
display
FtpClient
navigating JTextFields via up/down keys
Enums (Is this the best way)?
string contains a TAB will not be recognized in drawString(String str,int x, int y) method