Regex (?:[,\\\\. ]*(&|and) ?)
is not matching ", and "
. But when i change the matcher to (?:[,\\\\.] ?(&|and) ?)
the pattern ", and "
is getting matched. What is causing pblm?
When i remove the space from [,\\\\. ]*
[,\\\\. ]*
it seems working. I simply dnt understand.
I can find the match even with the space. It would be helpful if you can post the exact code.
Pattern p = Pattern.compile("(?:[,\\. ]*(&|and) ?)");
Matcher matcher = p.matcher(", and ");
System.out.println("Match? " + matcher.find());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.