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

Re^3: Regex to match non image urls

by userdefinable (Initiate)
on Jan 18, 2013 at 09:36 UTC ( #1013998=note: print w/replies, xml ) Need Help??

in reply to Re^2: Regex to match non image urls
in thread Regex to match non image urls

Basically this doesn't work:
$text =~ s~(\[img\]\s*.*?\.(?:jpe?g|png|svg|gif|bmp)\s*\[/img\])~Inval +id~isg;

Replies are listed 'Best First'.
Re^4: Regex to match non image urls (Parse::BBCode)
by Anonymous Monk on Jan 18, 2013 at 10:01 UTC
    You want to use Parse::BBCode, but you could try
    $text =~ s{ \[(\w+)\] # $1 tagname ( .*? ) # $2 stuff \[\/(\w+)\] # $3 tagname }{ TagFudge( $1, $2, $3 ); }gsex; sub TagFudge { my( $open, $content, $close ) = @_; if( $content =~ m{\.(jpe?g|gif|xbm|png|bmp)$} ){ return "Ok"; } else { return "Invalid"; } }
    But you should use Parse::BBCode
      Could't get that to work, it just says everything is invalid.
        Ah ha it was missing brackets on the tag parts. Works great now, thanks :)
Re^4: Regex to match non image urls
by muba (Priest) on Jan 18, 2013 at 11:19 UTC

    "Doesn't work" is not a problem description.

    Are you sure $text is what you think it is? You can try to do a print "\n>$text<\n"; and see if it matches your expectations.

    If $text is what you think it is, then how doesn't it work? What is your input, what is your expected output, what is your actual output? And with "actual output" I also mean warnings and errors. On that topic, is your script running with use strict; use warnings;?

Re^4: Regex to match non image urls
by userdefinable (Initiate) on Jan 18, 2013 at 10:06 UTC
    Right now it's doing the exact opposite of what I want it to!
      Yes, and?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013998]
[talexb]: TStanley I'm flying to Vegas in two weeks time. After that flights leaving Vegas and Phoenix are late at night .. I've been hearing that it gets so hot that the air isn't dense enough for planes to take off. Weird. Guess you won't have that problem.
[Corion]: Yay, vacation time now - one week off work (but a Perl workshop in the middle ;)) )
[talexb]: TStanley I just realized that I was in your area for a convention back in April. We were at the high school for the weekend, the one with the long driveway. Nice spot.
[TStanley]: I am heading to Arlington, Virginia next week, then I get to spend an entire week at home. Looking forward to that as I will have spent 7 weeks on the road by the end of next week

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-06-23 14:16 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (548 votes). Check out past polls.