in reply to regular expression search and replace
Your replacement has to be something tangible, not a pattern. However you can use the /e modifier to execute code in the replacement. Combining this with a capture group works like this:
#!/usr/bin/perl use strict; use warnings; my $line = "perlmonk is a gREat site. i loVE it.\n"; print $line; $line = ucfirst lc $line; print $line; $line =~ s/(\. [a-z])/uc($1)/eg; print $line;
Giving this output:
perlmonk is a gREat site. i loVE it. Perlmonk is a great site. i love it. Perlmonk is a great site. I love it.
Be sure to have a good read of perlre as regexes and the s/// function are bedrocks of Perl.
HTH, Hippo
|
|---|