I want to extract 12345 Rial from the String s :
String regx= ".* (\\d*) Rial";
String s = "your balance is 12345 Rial your last"
Pattern pattern = Pattern.compile(regx);
Matcher matcher = pattern.matcher(s);
System.out.println(matcher.group(1));
but the following exception is being thrown
java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Unknown Source)
at ir.dena.avl.server.util.modbus.ChargeMessage.getBalanceFromIranCell(ChargeMessage.java:95)
Can anyone point out why?