Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: regex problem

by robartes (Priest)
on Jun 08, 2005 at 09:41 UTC ( #464614=note: print w/ replies, xml ) Need Help??


in reply to regex problem

You're probably looking for something along these lines:

/^If[^f]/ # If followed by anything that is not f

The regex /^If?/ matches both your cases because you're looking for I followed by 0 or more 1 f's, so even Ig would match. The /^If{1}/ also matches both because both strings start with If, i.e. I followed by exactly one f. The second string has an additional f, but that particular regex is not concerned about that.

Update: rev_1318 is right, of course (see this node)

CU
Robartes-


Comment on Re: regex problem
Select or Download Code
Re^2: regex problem
by mosh (Scribe) on Jun 08, 2005 at 09:59 UTC
    Thanks for the detailed explanation !

    Mosh.

Re^2: regex problem
by rev_1318 (Chaplain) on Jun 08, 2005 at 10:20 UTC
    The regex /^If?/ matches both your cases because you're looking for I followed by 0 or more f's

    Actually, that's 0 or 1 f's, not 0 or more :) (but who's counting)

    Paul

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-25 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls