summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regcomp.c13
-rw-r--r--t/re/re_tests6
2 files changed, 16 insertions, 3 deletions
diff --git a/regcomp.c b/regcomp.c
index a837306733..34261129fa 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -9700,9 +9700,16 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
ret = reg_node(pRExC_state, NOTHING);
- /* But the quantifier includes any '?' (the non-greedy
- * modifier) after the {}, [perl #118375] */
- if (RExC_parse < RExC_end && *RExC_parse == '?') {
+ /* But the quantifier includes any '?', the non-greedy
+ * modifier, after the {}, [perl #118375]
+ * Likewise the '+', the possessive modifier, and
+ * they can be combined too, '?+' is the possessive
+ * non-greedy modifier.
+ */
+ if (RExC_parse < RExC_end && *RExC_parse == '?' ) {
+ nextchar(pRExC_state);
+ }
+ if (RExC_parse < RExC_end && *RExC_parse == '+' ) {
nextchar(pRExC_state);
}
return ret;
diff --git a/t/re/re_tests b/t/re/re_tests
index ae28e141e1..45018df71b 100644
--- a/t/re/re_tests
+++ b/t/re/re_tests
@@ -1744,4 +1744,10 @@ m?^xy\?$? xy? y $& xy?
/(a|(bc)){0,0}?xyz/ xyz y $& xyz
/( a | ( bc ) ) {0,0} ? xyz/x xyz y $& xyz
+/(a|(bc)){0,0}+xyz/ xyz y $& xyz
+/( a | ( bc ) ) {0,0} + xyz/x xyz y $& xyz
+
+/(a|(bc)){0,0}?xyz/ xyz y $& xyz
+/( a | ( bc ) ) {0,0} ? + xyz/x xyz y $& xyz
+
# vim: softtabstop=0 noexpandtab