• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

I need a regular expression...

Hello,
I need a regular expression (I'm not familiar with them), to be used with String.replaceall. It needs to match and replace the following characters comma, double quote, carriage return, and linefeed. If you could also explain how it works so that I can start learning how to do this that would be great.

Worth 500 points.

Thanks,
Rick
0
richardsimnett
Asked:
richardsimnett
2 Solutions
 
CEHJCommented:
s = s.replaceAll("[,\"\r\n]", "");

There's not much to explain other than it taking any of the chars in the character class and replacing them with an empty String
0
 
StillUnAwareCommented:
replaceAll("[,\"\n\r]", "what ever string to be instead of those chars");

All info about regex is in class java.util.regex.Pattern overview
0
 
ozoCommented:
[,\"\r\n]
0
 
objectsCommented:
[] defines characters classes, in this case to match any character character listed
carriage return is specified by \r
new line is specified using \n
" needs to be escaped in a java string \" so it isn't treated as closing the string
0
 
CEHJCommented:
:-)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now