brewzzer has asked for the wisdom of the Perl Monks concerning the following question:
Novice perl user here asking for a bit of help. I have a bunch of data that was badly formatted to contain strings like this:
Washington, D.c.
and
New York, N. y.
I'm trying to process the data to correct these instances, ie change 'D.c.' to 'D.C.' etc.
This is what I tried:
$this_term = 'Washington, D.c.'; $this_term =~ s/\.[a-z]/\.[A-Z]/g; print "$this_term";
I get this:
'Washington, D.A-Z.' instead of the desired 'Washington, D.C.'
Can someone show me what I'm doing wrong? I've spent a stupid amount of time on this, and I know the solution must be simple, but I can't find it.
Thanks gang.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replacing part of a string with its uppercase via regex
by choroba (Cardinal) on Mar 16, 2014 at 21:44 UTC | |
|
Re: replacing part of a string with its uppercase via regex
by AnomalousMonk (Archbishop) on Mar 16, 2014 at 21:47 UTC | |
|
Re: replacing part of a string with its uppercase via regex (replacing part of a string with its uppercase)
by shmem (Chancellor) on Mar 16, 2014 at 23:40 UTC | |
|
Re: replacing part of a string with its uppercase via regex
by brewzzer (Novice) on Mar 17, 2014 at 00:20 UTC | |
by Bod (Parson) on Jan 05, 2023 at 18:43 UTC |