diff options
author | Karl Williamson <public@khwilliamson.com> | 2010-08-18 23:48:16 -0600 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2010-09-20 08:13:30 +0200 |
commit | fb85c0447bf1d343a9b4d4d7075184aeb4c9ae46 (patch) | |
tree | 47c8406e939af312e69568c7a9ced9ec7d3529ed /regexp.h | |
parent | 5c3fa2e7f75bb4370f758b363cec53992c7fd20a (diff) | |
download | perl-fb85c0447bf1d343a9b4d4d7075184aeb4c9ae46.tar.gz |
Add (?^...) regex construct
This adds (?^...) to signify to use the default regex modifiers for the
cluster or embedded pattern-match modifier change. The major purpose of
this is to simplify regex stringification, so that "^" is output in
place of "-xism". As a result, the stringification will not change in
the future when new regex modifiers are added, so tests, etc. that rely
on a particular stringification will have to change now, but never
again.
Code that needs to work properly with both old- and new-style regexes
can use something like the following:
# Accept both old and new-style stringification
my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? '^' : '-xism';
This construct is Ben Morrow's idea.
Diffstat (limited to 'regexp.h')
-rw-r--r-- | regexp.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -236,6 +236,10 @@ and check for NULL. case SINGLE_PAT_MOD: *(pmfl) |= RXf_PMf_SINGLELINE; break; \ case XTENDED_PAT_MOD: *(pmfl) |= RXf_PMf_EXTENDED; break +/* Note, includes locale */ +#define STD_PMMOD_FLAGS_CLEAR(pmfl) \ + *(pmfl) &= ~(RXf_PMf_FOLD|RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_EXTENDED|RXf_PMf_LOCALE) + /* chars and strings used as regex pattern modifiers * Singlular is a 'c'har, plural is a "string" * |