polkadot
asked on
Need help with regular experssion in Java and escape characters
I want to remove the string "{x=0}" from text. Not sure how to represent {
String text;
String regex = "/{"; //this gives compile error: illegal escape character
text = text.replaceAll(regex, "");
if I use the other \{ it will run but gives me run time error about illegal escape sequence ..
aslo how do I use this method to replace a sequence of spaces and tabs from text? what would be the regex?
String text;
String regex = "/{"; //this gives compile error: illegal escape character
text = text.replaceAll(regex, "");
if I use the other \{ it will run but gives me run time error about illegal escape sequence ..
aslo how do I use this method to replace a sequence of spaces and tabs from text? what would be the regex?
String regex = "\\{x=0\\}";
ASKER
and about spaces? see question
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
\s Matches any white space character including space, tab, form-feed, and so on.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
polkadot - i'm confused by your treatment of this question. I answered both the main question here and the 'subquestion' yet
a. the comment marked as the accepted answer relates merely to syntax in a different language.
and
b. The other comment marked as 'assisted' repeats info i'd already given.
Why?
a. the comment marked as the accepted answer relates merely to syntax in a different language.
and
b. The other comment marked as 'assisted' repeats info i'd already given.
Why?
CEHJ ,
The second comment was given in split seconds of time. And I am late.
If you think, you deserve the points. no problem. I am ready to give the points.
And finally it's polkadot's decision. If he/she is willing to reopen and reassign the points
Regards
Sudhakar
The second comment was given in split seconds of time. And I am late.
If you think, you deserve the points. no problem. I am ready to give the points.
And finally it's polkadot's decision. If he/she is willing to reopen and reassign the points
Regards
Sudhakar
>>The second comment was given in split seconds of time.
Don't worry - i'm not blaming you sudhakar
Don't worry - i'm not blaming you sudhakar