Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Regex probleme, how memorize (match)? with question mark ?

by epoptai (Curate)
on Jul 06, 2001 at 23:52 UTC ( #94582=note: print w/ replies, xml ) Need Help??


in reply to Regex probleme, how memorize (match)? with question mark ?

This should match anything after mailto: that isn't a " and ends with "> and put it in $1.

if (/href="mailto:([^"]*)">/) { print "MATCH - ($1)" } else { print "DONT MATCH" }

--
Check out my Perlmonks Related Scripts like framechat, reputer, and xNN.


Comment on Re: Regex probleme, how memorize (match)? with question mark ?
Download Code
Re: Re: Regex probleme, how memorize (match)? with question mark ?
by tachyon (Chancellor) on Jul 07, 2001 at 00:07 UTC

    Nice regex but you don't need the trailing >. It adds nothing and will cause something that like mailto:foo@bar.com"  > to fail. Either drop it or allow for 0 or more spaces with a \s*

    (/href="mailto:([^"]*)">/     # may fail
    (/href="mailto:([^"]*)"\s*>/  # allows legal spaces
    (/href="mailto:([^"]*)"/      # best option, just match
                                  # what we want
    

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      True. In order to prevent legal whitespace breaking the match there's still some work left undone around the = sign:
      /href\s*=\s*"mailto:([^"]*)"/
      Of course this will still fail by only making a partial match if the email value has a double-quote (unlikely).

      --
      Check out my Perlmonks Related Scripts like framechat, reputer, and xNN.

        And this can still fail because HREF and MAILTO: in caps are valid so we need a /i to make it case insensitive

        /href\s*=\s*"mailto:([^"]*)"/i

        Are we there yet?

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      All right guyz, but you forgot the second statement.
      This regex need to match :

      $_ = '<A class=Title>';

      Your RE match only if there's an "href".

      BobiOne KenoBi ;)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2015-07-03 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls