Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regex match last

by ww (Bishop)
on Aug 20, 2012 at 10:38 UTC ( #988427=note: print w/ replies, xml ) Need Help??


in reply to Regex match last

Alternate:

C:\>perl -E "my $str='<c:t="AD2343"/><c:p>65677676</c:p>'; if ( $str = +~ m|(<c:.*)?(?:[/>]{2})| ) {say $1;}" <c:t=AD2343

Your code asks the regex engine to match a 'c', a colon and any number of anything thereafter(except newlines).

Because you didn't provide the actual code, we can't be sure just what other issues may be in play... such as the previously mentioned use of an alternate regex marker.

Update (based on the redefined problem in Re^2: Regex match last): You'll probably have fewer problems in the long run if you use an html parser of one flavor or another, rather than trying to parse html with regexen.


Comment on Re: Regex match last
Download Code
Re^2: Regex match last
by Anonymous Monk on Aug 20, 2012 at 10:55 UTC

    I am just capturing a group in the xml and replacing it with another group. I did'nt think that is parsing. Is it?

      It's called parsing whenever you want to do anything with (specific bits of) the data you read :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2014-10-01 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (34 votes), past polls