simple regex

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

hello this is what I am trying to do. I know it is fairly easy with regex unfortunately I really suck at it.

if ($this =~ m/any letter/g) {
execute..
}

so if scalar $this contains anything other then a number then it will excute this if statement.

Thanks for your help!
ken

Pimpin like a pimp with an electrofied pimpin machine!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I'm not the best at regex, but try this:

if ($this =~ m/^[^0-9]*$/g) {
    # string without any numeric characters
}
if ($this =~ m/^[a-zA-Z]*$/g) {
    # string containing only alpah characters
}
'

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.