in reply to Re^4: regex find and replace with a twist
in thread regex find and replace with a twist
Ugh .. I hate mis-reading the specs.
tab@music3:~/2018-0717$ cat pm.pl #!/usr/bin/perl use strict; use warnings; { my $word = '$-.%'; my $new_word = join ( '', map { "[$_]" } split /[a-zA-Z]/, $word ) +; print "$word -> $new_word\n"; } tab@music3:~/2018-0717$ perl pm.pl $-.% -> [$-.%] tab@music3:~/2018-0717$
In addition, I should have used // in my original call to split, as it takes a regex and not a string. Thanks for the reminder.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: regex find and replace with a twist
by haukex (Archbishop) on Jul 17, 2018 at 13:21 UTC | |
by talexb (Chancellor) on Jul 17, 2018 at 17:43 UTC | |
by AnomalousMonk (Archbishop) on Jul 17, 2018 at 18:12 UTC | |
by talexb (Chancellor) on Jul 18, 2018 at 03:14 UTC | |
by dsheroh (Monsignor) on Jul 18, 2018 at 07:19 UTC | |
by AnomalousMonk (Archbishop) on Jul 18, 2018 at 12:54 UTC | |
by talexb (Chancellor) on Jul 19, 2018 at 13:58 UTC |