Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: questions of a perl beginner on regex

by derby (Abbot)
on Jun 20, 2006 at 12:24 UTC ( [id://556369]=note: print w/replies, xml ) Need Help??


in reply to questions of a perl beginner on regex

Others have answered your question. Basically you have three different types of question marks: ?:, \? and ? - non capturing matching, escaping, and zero or more matches. But looking at that regex, I wonder if it's all just overkill. It looks like your matching a flash url that may have paramaters. I wonder if this simpler regex will do the job as well:

m/\.swf.*$/oi
Comments? I know some people wish death to dot-star but what's the downside here?

-derby

Replies are listed 'Best First'.
Re^2: questions of a perl beginner on regex
by jhourcle (Prior) on Jun 20, 2006 at 13:52 UTC

    Maybe, maybe not. I think it's overkill, but your proposal is too simple. It might cause false matches if there were a 'www.swf.com' (or even 'www.swfa.com')

    I'd probably use something like:

    m/[.]swf(?:$|[?])/i

    if we're not capturing, there's no reason to need '.*' to get the rest of the line, so a simple alternate (end of line, or a question mark), will work just fine.

    It's almost as few characters to use the following, and there would hopefully be less confusion about what it's doing for novices:

    m/\.swf$|\.swf\?/i

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found