Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^2: change [A-Z] to U, [a-z] to L with one regex?

by LanX (Bishop)
on Mar 20, 2013 at 01:20 UTC ( #1024408=note: print w/replies, xml ) Need Help??

in reply to Re: change [A-Z] to U, [a-z] to L with one regex?
in thread change [A-Z] to U, [a-z] to L with one regex?

what about punctuation and numbers? =)

my 2

DB<141> $r = 'SomEThingWithMIXEDRegiSter;.?=356'; => "SomEThingWithMIXEDRegiSter;.?=356" DB<142> $r =~ s/(.)/ $1 eq "\u$1" ? ($1 eq "\l$1" ? $1 : "U" ) : ($1 + eq "\l$1" ? "L" : "X" ) /ge => 33 DB<143> $r => "ULLUULLLLULLLUUUUUULLLULLL;.?=356"

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^3: change [A-Z] to U, [a-z] to L with one regex?
by ikegami (Pope) on Mar 20, 2013 at 06:58 UTC
    I'm pretty sure $1 eq "\u$1" can fail for some characters it shouldn't fail for.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024408]
[choroba]: I wouldn't want to maintain it in the current form
[erix]: ok, but mainainability comes after it has been made to work :)
[erix]: maybe I should have cobbled together a more simple example
[erix]: the main question is whether repeating groups get captured. I thought they did but it looks they do not.
[erix]: or they probably get overwritten when the repeating is done

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2018-01-19 08:39 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (216 votes). Check out past polls.