Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Replacing Text

by mreece (Friar)
on Apr 05, 2007 at 22:50 UTC ( #608566=note: print w/replies, xml ) Need Help??


in reply to Replacing Text

expect a lot of answers directing you towards various html scrubbers and token parsers, but here is the dirty regex:
s{(?:<a\s[^>]+>)([^<]+)(?:</a>)}{$1}g;
there are a lot of assumptions in there, like the link label doesn't contain < (ie, <img>), there are no line breaks, HTML is well-formed, no embedded comments (<a <!--oops--> href="">...</a>), etc, etc. but if all your use cases are like the example there, it will work.

Replies are listed 'Best First'.
Re^2: Replacing Text
by pyro.699 (Novice) on Apr 05, 2007 at 23:09 UTC
    Well, some of them do have images in the link, and i have a feeling that it will make it even more complicated... lol Thanks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2023-03-26 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?