in reply to Can anyone make this regex job neater?
I was just curious is there was a more elegant way to do this - preferably a single s///, rather than one match and two substitutions. Thanks in advance...This smells a lot like homework, so I'm not posting a full answer -- hints only! In any case I'd also take into account split, and then of course you can join again with '|' (too explicit a hint?!?).
Whatever, there's nothing wrong using two or more statements: it may well be doable with a single s///, but it would just be an exercise in doing it the difficult way. Your code must also be clear, mantainable and easy to understand. Incidentally you may also do
for ($stuff[2]) { s/(?=[A-Z])/U/g; s/(?=[a-z])/L/g; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can anyone make this regex job neater?
by Melly (Chaplain) on Oct 11, 2005 at 18:59 UTC | |
by GrandFather (Saint) on Oct 11, 2005 at 19:56 UTC | |
by blazar (Canon) on Oct 12, 2005 at 07:47 UTC |