Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: what is the best way to seperate the digits and strings from variable ?

by Tanktalus (Canon)
on May 09, 2005 at 14:39 UTC ( [id://455193]=note: print w/replies, xml ) Need Help??


in reply to Re^3: what is the best way to seperate the digits and strings from variable ?
in thread what is the best way to seperate the digits and strings from variable ?

Testing your code is a great concept. Of course, we all have to agree on the specs so we can all agree on what tests are needed. Your code works just fine for a certain subset of possibilities, dbwiz's code works just fine for a different subset of possibilities, both work just fine for the subset of posssibilities as presented by the OP. In the absence of a better spec, we all make assumptions that show the world that we, individually, live in more than they show the world that the OP lives in. (Which is why, if you look back at questions I pose, they're usually quite long-winded - to reduce the "absence of a better spec".)

As for the initial letters, not that we're straying from the initial thread here ;-), I'd recommend matching with /^([[:alpha:]]*)/ instead. Again, we have to agree on a spec of what "initial letters" means (does it mean English letters, or can it include accented characters, or letters in other non-Roman lettering systems?). If it includes other languages, I like letting perl worry about that stuff for me ;-). Note that it is perfectly reasonable to only accept straight-ascii for some things. We just can't tell from what has been stated so far. (And I've just revealed a bit more about the world I live in.)

  • Comment on Re^4: what is the best way to seperate the digits and strings from variable ?
  • Download Code

Replies are listed 'Best First'.
Re^5: what is the best way to seperate the digits and strings from variable ?
by polettix (Vicar) on May 09, 2005 at 15:46 UTC
    In doing some theatre I think it's (should be) allowed to stretch specs at will - at least, until they don't STRRRRAAAAAAAPPP miserably! I'm a lazy guy (as you implicitly, and correctly, noted with your /^([[:alpha:]]*)/ regex :), but I couldn't accept that reply the very time I've actually actively thougth about "+" and "*"!

    One of the things that PM lacks is a pub section, were dbwiz and I could enjoy a beer laughing about all that! (Others would be welcome as well).

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-25 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found