suse :
There is a regex and I need to find the character not matching the regex. Then replace the character with "" in. How to achieve this in JAVA?
Pattern : ^((?![\|\=\;])[\p{L}\p{N}\p{M}\p{P}\p{Zs}])+$
Sample Text: HAIRCUT $42 PER PERSON
Required output: HAIRCUT 42 PER PERSON
user557597 :
Just negate what you already have.
Find (?!(?![|=;])[\p{L}\p{N}\p{M}\p{P}\p{Zs}])[\S\s]
Replace nothing
https://regex101.com/r/Sn3DuL/1
(?!
(?! [|=;] )
[\p{L}\p{N}\p{M}\p{P}\p{Zs}]
)
[\S\s]