Regular expressions in java can be easily handled by the java.util.regex package. You can also find the regular expression sintax in Regular expression documentation
Besides, in this tutorial you will find an example to use this package wich basically uses two classes: java.util.regex.Matcher and java.util.regex.Pattern;
One possible solution to your question would be:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegExMatches {
public static void main( String args[] ){
// String to be scanned to find the pattern.
String line="{\"Id\":\"490145\",\"Index\":null,\"Type\":\"BOOK\"}";
String pattern = "(\\d+)";
// Create a Pattern object
Pattern r = Pattern.compile(pattern);
// Now create matcher object.
Matcher m = r.matcher(line);
if (m.find( )) {
System.out.println("Found value: " + m.group(0) );
} else {
System.out.println("NO MATCH");
}
}
}
Instead, if you want to obtain the value of each field (Id, Index and Type), the pattern should consist of 6 groups (I assumed the Index composed of characters and not numbers):
String pattern = "(\"Id\":\")(\\d+)(\",\"Index\":)(\\w+)(,\"Type\":\")(\\w+)";
While the outputs would be:
System.out.println("Found value for Id: " + m.group(2) );
System.out.println("Found value for Index: " + m.group(4) );
System.out.println("Found value for Type: " + m.group(6) );