[Solved] Java String replace Regular Expression


Use this:

String replaced = yourString.replaceAll("[^\\w\\xAE\\xA9~. -]", "_");
  • In Java, \w matches all ASCII letters, numbers and underscore
  • A9 and AE are the hex codes for copyright and registered trademark

1

solved Java String replace Regular Expression