• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parsing using Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic