I am using PCRE regex and i would like to capture the string between the tag ?31 and the next ?xx tag but this next ?xx tag could be an optional tag
is there anyway to make the regex to do exactly like what i want?
Thanks
Regex | Input | Captured group | Status |
---|---|---|---|
\?31(.*)(?:\?\d{2}) | xxx?31testing1?32testing2 | testing1 | OK |
\?31(.*)(?:\?\d{2}) | xxx?31testing1 testing2 | N/A | NOT OK, should be 'testing1 testing2' |
\?31(.*)(?:\?\d{2})? | xxx?31testing1?32testing2 | testing1?32testing2 | NOT OK, as ?32 is captured together |
\?31(.*)(?:\?\d{2})? | xxx?31testing1 testing2 | testing1 testing2 | OK |
\?31(.*?)(?:\?\d{2})? | xxx?31testing1?32testing2 | N/A | NOT OK, should be 'testing1' |
\?31(.*?)(?:\?\d{2})? | xxx?31testing1 testing2 | N/A | NOT OK, should be 'testing1 testing2' |