Reputation: 13734
Test Cases :
Matches should be the 1st & 3rd one, since 2nd & 4th already contains escaped "$".
I tried - Pattern pattern=Pattern.compile("(^\\\\$)");
but it doesn't match any. Please help.
Upvotes: 0
Views: 45
Reputation: 70732
You can use Negative Lookbehind here to exclude the already escaped $
characters.
(?<!\\\\)\\$
Upvotes: 1