I was trying the pattern ^\\+[0-9]+
to match +852(2)78911
, but it seems that
Pattern.matches("^\\+[0-9]+", s)
is returning false
. When I tried it in regexr it is working fine i.e. giving me a match. Am I not escaping this correctly in Java sense?