diff options
author | David Caldwell <david@porkrind.org> | 2009-11-23 17:24:25 -0800 |
---|---|---|
committer | David Caldwell <david@porkrind.org> | 2010-05-22 02:28:22 -0700 |
commit | 4f4d7508b0c2c114e5f52420e0e87a853c5f642a (patch) | |
tree | 008d80915d83e246892b83fa06e46a3b2e21c6bf /regexp.h | |
parent | dd9035cd5bdeced1187df399d27d526f3b30194b (diff) | |
download | perl-4f4d7508b0c2c114e5f52420e0e87a853c5f642a.tar.gz |
Add s///r (non-destructive substitution).
This changes s/// so that it doesn't act destructively on its target.
Instead it returns the result of the substitution (or the original string if
there was no match).
In addition this patch:
* Adds a new warning when s///r happens in void context.
* Adds a error when you try to use s///r with !~
* Makes it so constant strings can be bound to s///r with =~
* Adds documentation.
* Adds some tests.
* Updates various debug code so it knows about the /r flag.
* Adds some new 'r' words to B::Deparse.
Diffstat (limited to 'regexp.h')
-rw-r--r-- | regexp.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -263,11 +263,13 @@ and check for NULL. #define SINGLE_PAT_MOD 's' #define IGNORE_PAT_MOD 'i' #define XTENDED_PAT_MOD 'x' +#define NONDESTRUCT_PAT_MOD 'r' #define ONCE_PAT_MODS "o" #define KEEPCOPY_PAT_MODS "p" #define EXEC_PAT_MODS "e" #define LOOP_PAT_MODS "gc" +#define NONDESTRUCT_PAT_MODS "r" #define STD_PAT_MODS "msix" @@ -276,7 +278,7 @@ and check for NULL. #define EXT_PAT_MODS ONCE_PAT_MODS KEEPCOPY_PAT_MODS #define QR_PAT_MODS STD_PAT_MODS EXT_PAT_MODS #define M_PAT_MODS QR_PAT_MODS LOOP_PAT_MODS -#define S_PAT_MODS M_PAT_MODS EXEC_PAT_MODS +#define S_PAT_MODS M_PAT_MODS EXEC_PAT_MODS NONDESTRUCT_PAT_MODS /* * NOTE: if you modify any RXf flags you should run regen.pl or regcomp.pl |