I need to write a java pattern to identify all special characters except "0123456789" or "(" or ")" or "|" or "-" or " ".
Can somebody help me to get an answer?
I wanted to use Pattern.compile and pattern.matcher to find out this.
I need to write a java pattern to identify all special characters except "0123456789" or "(" or ")" or "|" or "-" or " ".
Can somebody help me to get an answer?
I wanted to use Pattern.compile and pattern.matcher to find out this.
If you want to find all characters separately you can use this pattern-
/[^ 0123456789()|\-]/g
Or if you want to find blocks of consecutive characters, you should use this-
/[^ 0123456789()|\-]+/g
This will identify all characters except those inside [^(*this part*)]
By the way, if you want to research further about regex pattern http://regexr.com/ will be very helpful. There are quick references and tutorials to help you learn the basics of regex quickly.
