hanoo hanoo - 2 months ago 12
Android Question

android java regex named groups

I would like to use

matcher.group("login");


In android 8+ on eclipse, but no Matcher.group(String) seems to exist.
Have you got a (built in) solution ?

Answer

Android Pattern class implementation is provided by ICU, to be precise, ICU4C.

The regular expression implementation used in Android is provided by ICU. The notation for the regular expressions is mostly a superset of those used in other Java language implementations. This means that existing applications will normally work as expected, but in rare cases Android may accept a regular expression that is not accepted by other implementations.

And ICU4C currently doesn't support named capturing group. You have to fall back on numbered capturing groups.

ICU does not support named capture groups. http://bugs.icu-project.org/trac/ticket/5312

You need to write a wrapper and parse the expression yourself to provide named capturing group capability, if you really need the feature.