Compose a regular expression from other RegExp objects

Updated . Posted . Visible to the public.

You can create a Regexp Show archive.org snapshot object from existing Regexp objects by using the interpolation syntax you know from strings:

re1 = /x/
re2 = /a#{re1}b/
'aaxbb' =~ re2 # => 1

Note

If your regular expression contains backreferences like \1, they may no longer refer to the correct capture group after concatentation.

Henning Koch
Last edit
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-09-07 11:36)