Jump to content
Sign in to follow this  
peasepud

Regular Expressions

Recommended Posts

Seeing as our own resident Northern Ireland residing expert cant be arsed to help me because of some self centred need to gain promotion I need help from anyone that understands these. Ive tried many a time and frankly havent got a bastard clue!

 

I know it can be done and is fairly straight forward.

 

I want a regex that will add a bit to the start of any link in the document

 

ie <a href="http://www.bbc.co.uk">'>http://www.bbc.co.uk">

 

I want to change to

 

<a href="http://www.toontastic.net/result.php?theurl=http://wwww.bbc.co.uk">

 

at the same time there could be other bits in the link

 

eg

 

<a href="http://www.bbc.co.uk" title="BBC" />

 

or the http may be missing

 

<a href="www.bbc.co.uk"/>

 

or any one of a dozen other valid link setups.

 

therefore I need to find any <a tags and add in a bit between the speech mark and the next char regardless of whats shown etc

 

Anyone?

Share this post


Link to post
Share on other sites

(?:<a.*?href=[""'](?<url>.*?)[""'].*?>)(?<name>(?><a[^<]*>(?<DEPTH>)|</a>(?<-DEPTH>)|.)+)(?(DEPTH)(?!))(?:</a>)

 

should work for finding <A href="">WHATEVER</A>

 

had to do a bit of checking on that and if i'm honest i think certain urls will still break it

 

edit > blah maybe not *thinks*

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

Recent tweets

Toontastic Facebook

Donate to Toontastic

Keeping the lights on since... well ages ago
TT-Staff


×