I'm trying pattern matching expression for a below string. But it doesn't work. could you anybody help me on this ? Only Alphanumeric and underscore allowed inside,Both side $ sign will be there. Ex strings: Test_1,23_test_2,test3.
String text = "$test_1$";
Pattern p = Pattern.compile("$([A-Za-z0-9_])$");
Matcher m = p.matcher(text);
m.matches();
if (m.find()) {
System.out.println("Matched: " + m.group(1));
} else {
System.out.println("No match.");
}