require 5.013002; # or better: use Syntax::Construct qw(/r); print "bla: ", $myvar =~ s/a/b/r, "\n";
The substitution operator now supports a
/roption that copies the input variable, carries out the substitution on the copy and returns the result. The original remains unmodified.
my $old = 'cat'; my $new = $old =~ s/cat/dog/r; # $old is 'cat' and $new is 'dog'
- How do I perform a Perl substitution on a string while keeping the original?
- How do I match any character across multiple lines in a regular expression?
- Regular expression search replace in Sublime Text 2
- Match whitespace but not newlines
- How can I add a string to the end of each line in Vim?
- Regex to match any character including new lines
- Match everything except for specified strings
- What flavor of Regex does Visual Studio Code use?
- Visual Studio, Find and replace, regex
- How to match any non white space character except a particular one?
- Why it’s not possible to use regex to parse HTML/XML: a formal explanation in layman’s terms
- How to search for occurrences of more than one space between words in a line
- Eclipse, regular expression search and replace
- Escaping a forward slash in a regular expression
- Can you make just part of a regex case-insensitive?
- Capitalize first letter of each word in a selection using Vim
- The recognizing power of “modern” regexes
- What does $1 mean in Perl?
- Notepad++ Replace regex match for same text plus appending character
- Perform a non-regex search/replace in vim
- How can I store regex captures in an array in Perl?
- phpstorm replace array() notation to [ ] short syntax
- What regex can match sequences of the same character?
- How to match once per file in grep?
- How to replace a string in an existing file in Perl
- Should I use \d or [0-9] to match digits in a Perl regex?
- Find and replace whole words in vim
- How can I use a variable for a regex pattern without interpreting meta characters?
- regex implementation to replace group with its lowercase version
- How can I use a variable in the replacement side of the Perl substitution operator?
- Emacs: regular expression replacing to change case
- Removing non-alphanumeric characters with sed
- “Variable length lookbehind not implemented” but it isn’t variable length
- Why is `\s+` so much faster than `\s\s*` in this Perl regex?
- Are Perl regexes turing complete?
- find & replace commas with newline on Google Spreadsheet
- Adding characters at the start and end of each line in a file
- Reference – What does this regex mean?
- Negative regex for Perl string pattern match
- Regex Group in Perl: how to capture elements into array from regex group that matches unknown number of/multiple/variable occurrences from a string?
- Perl iterate through each match
- How can I exclude some characters from a class?
- Reference – Password Validation
- Replace a word with multiple lines using sed?
- How can I match a quote-delimited string with a regex?
- Replace single backslash in R
- Notepad++ Regex Backreference syntax in Search/Replace – \1 or $1
- Does the ‘o’ modifier for Perl regular expressions still provide any benefit?
- Regex to check if valid URL that ends in .jpg, .png, or .gif
- Counting number of occurrences of a string inside another (Perl)