vendredi 6 décembre 2019

ECMA Script check if group is defined

I am trying to rewrite some Python expression to C++ with usage of std::regex with ECMASynax.

Here is the original expression:

(?P<lower_bound>(?P<lower_bound_prefix>>|>=)?(?P<lower_version>([0-9a-zA-Z_]+(?:[.-][0-9a-zA-Z_]+)*))?(?(lower_bound_prefix)|\+))$

I replaced all name capture groups to unnamed groups. Unfortunately, I can't make the last condition to happen. How can I represent this Python re syntax: ?(lower_bound_prefix) in ECMASynax? I know I can reference groups using \int syntax, but how can I check if group has been defined?

Thanks

Aucun commentaire:

Enregistrer un commentaire