Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Quick question about pattern matching uppercase letters

by mce (Curate)
on Apr 27, 2004 at 14:47 UTC ( #348520=note: print w/replies, xml ) Need Help??

in reply to Quick question about pattern matching uppercase letters


Some context code would be nice.

Anyway, this should do the trick

perl -p -e "s|\b([A-Z]+)\b|<i>\1</i>|g;" yourfile

Dr. Mark Ceulemans
Senior Consultant
BMC, Belgium

Replies are listed 'Best First'.
Re: Re: Quick question about pattern matching uppercase letters
by dragonchild (Archbishop) on Apr 27, 2004 at 14:52 UTC
    Better is s|\b([A-Z]+)\b|<i>$1</i>|gm;. Don't use backreferences if you don't have to. They're difficult to debug when they have an error. Plus, you'll need the /m modifier to match across multiple lines.

    Update: As pointed out to me, /m isn't needed here. This is a case of learning a rule early and never learning the reasons behind the rule. (/m is for "multiple lines")

    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      //m changes the meaning of ^ and $ and there aren't any of those there, so it isn't needed. //m doesn't do anything else. And using \1 on the right side of a subst isn't actually a backreference and doesn't make anything harder to debug, it's just deprecated syntax.

      The use of \1 is a sign that the poster forgot to enable warnings, though.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://348520]
[Corion]: Krug is generic pottery ware for pouring beverages, but a Bembel is painted with that blue paint and contains only (!) Apfelwein
[shmem]: Corion: alas, air too.
[Corion]: shmem: Yes, very sad!
[choroba]: doesn't sound much useful, which means I'll probably remember it
[karlgoethebier]: "that blue pain" == Salzglasur as far as i remember
[karlgoethebier]: Paint!
[shmem]: karlgoethebier the blue pain comes after all bembels are empty
[karlgoethebier]: Confusing "Bembel" with "Membel" might result in a slap in the face in Hesse...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-05-24 08:55 GMT
Find Nodes?
    Voting Booth?