import java.util.regex.*;
class Regex {
public static void main(
String [] args) {
Pattern p = Pattern.compile(args[0]);
Matcher m = p.matcher(args[1] );
boolean b = false;
System.out.println("Pattern is " + m.pattern());
while(b = m.find()) {
System.out.println(m.start() + " " + m.group());
}
}
}
%
java Regex "\d\w" "ab4 56_7ab"
Produces the output
Pattern is \d\w
4 56
7 7a
how can i know how \d\w pattern works
eg if we looking for a digit (\d)we will gey the 4 which has index 2
and the
word wg we may get the whole 56_7ab which start at index 4
is digit && word
or digit || word
i really dont understant how those metacharcters works together as in the exmaple \d\w