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

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

command line - Use qwinsta in PowerShell ISE -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -