Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

(Dermot) RE: Re: Big

by Dermot (Scribe)
on Sep 28, 2000 at 04:36 UTC ( #34309=note: print w/ replies, xml ) Need Help??


in reply to (Dermot) Re: Big
in thread Big, bad, ugly regex problem

Ovid, this is what I came up with after messing with it for a while. It handles the two input strings you were having problems with (quote characters are not optional) but I've no idea if it will work for all possible data. The quote characters optional we can talk about tomorrow.

#!/usr/bin/perl -w use strict; my ($data, $res); $data = '<a & href="somesite.html">test<\a>'; print "Before substitution: $data\n"; $res = $data =~ s/ ( # Capture to $1 <a and <a\s # a space character ) (?: # Non-capturing parens [^>]* # stuff between a and href ) ( href\s* # href followed by spaces ) ( =\s* # Equals followed by spaces ( ["']+ # Open quote character ) ( [^"']+ # Non open quote character ) (?: \4 # Close quote character ) ) ( > # Not final close angle bracket ) ( [^>]+ # Up to closing angle bracket > # Final close angle bracket ) /$1$2$3$6$7/x; print "no match\n" if ($res eq ""); print "After substitution: $data\n";


Comment on (Dermot) RE: Re: Big
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2014-08-30 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (292 votes), past polls