Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Regex question

by robot_tourist (Hermit)
on May 22, 2007 at 09:58 UTC ( #616715=note: print w/ replies, xml ) Need Help??


in reply to Regex question

If your second variable is always 3 characters and the first is always at least three characters, then it's not too hard, you could see if a substring of var1 eq var2. Or even the following works for me

if ($var1 =~ /^$var2/) { print "matched"; }

Or you could do character by character comparisons. I'm sure in this case there are many ways to do it, though it would get complicated if you wanted to do a compare where $var1 used periods and $var2 used underscores or something.

UPDATE: 20070522 11:01 localtime > ++ to BrowserUK for index

UPDATE: 20070522 11:57 localtime > got a pm (thought it was a reply) and can't remember who sent it now, but props to the monk in question for reminding me to anchor the regex with ^

How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
Robot Tourist, by Ten Benson


Comment on Re: Regex question
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-10-21 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (99 votes), past polls