Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Java in General and the fly likes String replacement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "String replacement" Watch "String replacement" New topic

String replacement

Ranadhir Nag
Ranch Hand

Joined: Mar 09, 2006
Posts: 138
How do we prepend all expressions in a specified list,with an excape character,in the shortest possible way.
Suppose ,we have a string - "Are+we @in /for a ? surprise"
We need an output string which looks like "Are\+we \@in \/for a \? surprise"
What is the smartest way of achieving this?
Laxmikant Ruikar

Joined: Nov 29, 2005
Posts: 23
Use regular expression pattern to replace string...

Piet Verdriet
Ranch Hand

Joined: Feb 25, 2006
Posts: 266
Here's a way:

I agree. Here's the link:
subject: String replacement
It's not a secret anymore!