I am using this simple code:
if (data.matches("(\\d+)\\D+"))
data = "$1";
I want to find a string that begins with a number and then have non-number string. I need to extract the number itself. The backreference doesn't work. I am getting that data equals literally $1 instead of the matched expression. What am I doing wrong?