I want to replace char ‘&’ if it’s not followed by ‘#’. For example in this string "& hello &# world!" I’d want to select only the first ‘&’.
So far I came up with this regex:
&[^#]
However, this selects 2 characters, whereas I want to only select the ampersand character.
Any help from RegExp Gurus would be appreciated.
BTW. It may be important: I want to use it in java replaceAll().
Many thanks,
Damo
Using negative lookahead:
Prints: