#!/usr/bin/perl use warnings; use strict; sub replace { s/$_[0]/$_[1]/eeg; } $_ = 'a { b } c ( d ) e'; my $nobrackets = qr/[^{}]+/; replace(qr/\{($nobrackets)\}/, '$1'); print "$_\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex - Is there any way to control when the contents of a variable are interpolated? (Using "$1" and '$1' in regex replacements)
by JDoolin (Novice) on Mar 14, 2014 at 17:12 UTC | |
by AnomalousMonk (Archbishop) on Mar 15, 2014 at 00:41 UTC | |
by JDoolin (Novice) on Mar 15, 2014 at 18:58 UTC |