java - Regular Expression program from Predefined character classes -
public class regularexpressiondemo2 { public static void main(string[] args) { pattern p = pattern.compile("\\."); matcher m = p.matcher("a1b7 @z#"); while (m.find()) { system.out.println(m.start() + "-------" + m.group()); } } }
from docs, says .
symbol prints character how come above program doesn't print thing.
you double-escaped dot.
this means matching literal dot, not wildcard character.
your input not contain one, hence nothing gets printed.
change pattern
"."
.
Comments
Post a Comment