Wednesday, September 13, 2017

Replace Special Characters with Hyphen in a String


String value = 'tstu# is @ ' d ,s . "; dfs:';

value = value.replaceAll('[|,|.|\\,||"||:|~|!|@|#|$|%|^|&|*|_|+|=|<|>|?|\\(|\\)|\\{|\\}|\\;|\\\'"]', '-');

debug value: tstu is d s dfs:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.