in reply to Is Group Substitution Possible?
Output#!/usr/bin/perl -w $string = "Test: FileNames can't have / \\ and other special character +s"; $string =~ s/(.*):(.*)\/(.*)\\(.*)/$1COLON$2FSLASH$3BSLASH$4/; # Note +greedy substituion in place print $string,$/; my %subs = qw(: COLON / FSLASH \\\\ BSLASH); $string =~ s/$_/$subs{$_}/ for (keys %subs); print $string,$/;
TestCOLON FileNames can't have FSLASH BSLASH and other special charact +ers TestCOLON FileNames can't have FSLASH BSLASH and other special charact +ers
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is Group Substitution Possible?
by ketema (Scribe) on Jul 28, 2005 at 20:11 UTC |