I have a requirement to clean a string for illegal barcode-39 data and change each illegal charcter to whitespace. Currently the only valid characters in barcode-39 are 0-9,A-Z,-(dash),.(dot),$(dollar-sign),/(forward-slash),+(plus-sign),%(percent-sign) and a space.
I tried the following regular expression but it seems to only use the not operator in the first group of characters.
barcode = barcode.toUpperCase().replaceAll("[^A-Z0-9\\s\\-\\.\\s\\$/\\+\\%]*"," ");
The code seems to only interpret, If not A to Z then replace with space. How do I make it interpret, if not A-Z and not 0-9 and not dash and not dollar-sign and not forward-slash, and so on, then replace char with a space.
Any help would be great.