Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: regex for text manipulation

by snoopy (Deacon)
on Nov 07, 2007 at 06:39 UTC ( #649408=note: print w/ replies, xml ) Need Help??


in reply to regex for text manipulation

Here's one possible solution:

#!/usr/bin/perl use warnings;use strict; foreach (<DATA>) { s{ (^|\.) # Start of string, or last full-stop (.*?) # Non-alpha characters (non-greedy) ([a-zA-Z]) # First alphabetic character ([^\.]*) # Through to next full stop }{ $1.$2.uc($3).lc($4) }gex; print; } __DATA__ today is wednesday.tomorrow IS THURSDAY. I am trying to write a regex to convert the first letter and any lette +r following a full stop in a string to uppercase .and . all the ot +her characters to lowercase.


Comment on Re: regex for text manipulation
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://649408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-12-28 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (179 votes), past polls