jeudi 22 février 2018

Java regex with ^ symbol: find from position

I'm trying to find ^a{3} pattern in string, but not from beginning. From position 2

For example:

Pattern pattern = Pattern.compile("^a{3}");
Matcher m = pattern.matcher("xxaaa");
System.out.println(m.find(2));

It seems ^ means start of the string (not start of string from position 2)

But how to find pattern from position 2 and be sure that a{3} starts in this position

Aucun commentaire:

Enregistrer un commentaire