Hi all,
I am trying to use back references in Java regex, but it seems I'm not doing it the right way and can't get it work. I wanted to be able to match parts of string surrounded by 2 same quotes, say find if a string contains "whatever"
or 'whatever'
.
I then wrote the following code :
Pattern p = Pattern.compile("(\"|\')whatever\1");
Matcher m = p.matcher("'whatever'loremipsumblah");
System.out.println(m.find()); // always returns false
... but it seems the back reference is not working at all, as the matcher can't find any part of the string matching the pattern. I hope you guys will be able to help me cause I'm definitely stuck :|