diff options
author | Vance Shipley <[email protected]> | 2012-04-04 18:17:33 +0530 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2012-07-10 14:58:54 +0200 |
commit | 264e667b86381528131c45c9b6e8f54ad168c73f (patch) | |
tree | 9e13064162e668b38ffc867de62350e92336e93a /lib/stdlib/src | |
parent | c075ac6484e3d5a93a0d870ab4483d39ae26eaec (diff) | |
download | otp-264e667b86381528131c45c9b6e8f54ad168c73f.tar.gz otp-264e667b86381528131c45c9b6e8f54ad168c73f.tar.bz2 otp-264e667b86381528131c45c9b6e8f54ad168c73f.zip |
extend re back reference syntax with \g escape sequence
Add the \gN and \g{N} syntax for back references in re:replace/3,4
to allow use with numeric replacement strings.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/re.erl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/stdlib/src/re.erl b/lib/stdlib/src/re.erl index 246d535943..70566e48dd 100644 --- a/lib/stdlib/src/re.erl +++ b/lib/stdlib/src/re.erl @@ -355,6 +355,12 @@ apply_mlist(Subject,Replacement,Mlist) -> precomp_repl(<<>>) -> []; +precomp_repl(<<$\\,$g,${,Rest/binary>>) when byte_size(Rest) > 0 -> + {NS, <<$},NRest/binary>>} = pick_int(Rest), + [list_to_integer(NS) | precomp_repl(NRest)]; +precomp_repl(<<$\\,$g,Rest/binary>>) when byte_size(Rest) > 0 -> + {NS,NRest} = pick_int(Rest), + [list_to_integer(NS) | precomp_repl(NRest)]; precomp_repl(<<$\\,X,Rest/binary>>) when X < $1 ; X > $9 -> %% Escaped character case precomp_repl(Rest) of |