You need to sign in to do that
Don't have an account?
ShowerHammer
Need some help with replacing characters and regex patterns.
I currently an trying to replace all non-alphanumeric characters in a string and replacing everything but the space, would like that to be a hyphen, with a blank value to remove it and cannot figure out how to escape out commas, parenthesis, apostrophes, periods and colons.
The strings I am parsing could have any one of the characters below in them.
This is what I am using:
The strings I am parsing could have any one of the characters below in them.
This is what I am using:
foo = foo.replaceAll('[\\,"\\:~|!|@|#|$|%|^|&|*|_|+|=|<|>|?\\(\\)\\{\\}\\;\\\']', '');
foo = foo.replaceAl(' ','-');
foo = foo.replaceAl(' ','-');
I have tried using but cannot get this to work either.
foo = foo.replaceAll('![a-zA-Z0-9]', '');
Any help would be appreciated.
1. The first line doesn't have an "|.", so periods are eliminated.
2. The second line is missing an "l" in the replaceAll method name and would throw a compilation error.