in reply to substitution not working correctly
If I've understood you correctly, you need [^#]+ to match ungreedily by using the ? quantifier:
my %langhash; $langhash{'dígito verificador incorrecto.'} = 'digit incorrect.'; my $string = '(5/4/07 4:24:03 PM CDT) 1473721: ## dígito verificad +or incorrecto. ##pp'; if ($string =~ s/##\s*([^#]+?)\s*##/##$langhash{$1}##/) { print "$langhash{$1}\n"; print "/$1/\n"; print $string; }
Prints:
digit incorrect. /dígito verificador incorrecto./ (5/4/07 4:24:03 PM CDT) 1473721: ##digit incorrect.##pp
Is that what you're after?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitution not working correctly
by ikegami (Patriarch) on Sep 23, 2007 at 04:33 UTC |