Issue
I would like to create a regex to help me to delete only special characters except spelling accents. For example:
João Maria-JOSÉ!!!
I would like to print
João Maria JOSÉ
Heeeelp?
Solution
Use UNICODE_CHARACTER_CLASS
(?U)
together with the negation of the Alpha character class
\P{Alpha}
Example:
"João Maria-JOSÉ coração!!!".replaceAll("(?U)\\P{Alpha}", " ")
resulting in
"João Maria JOSÉ coração "
Answered By - user16320675
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.