Jump to content

Regular Expressions


  • Please log in to reply
3 replies to this topic

#1
peasepud

peasepud
  • Manager

  • 13,220 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">

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?
http://justasimplefan.wordpress.com/

#2
Howmanheyman

Howmanheyman
  • Corner Graduate.

  • 2,788 posts
I seriously worry about people who actually understand that post. :)
Posted ImagePosted ImagePosted Image

#3
Ant

Ant
  • Unethical and Power-mad

  • 10,910 posts
(?:<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*

So Jim, have I ever told you about the old country? The songs! Oh Jim, they'd melt your face.
"Ohh I live in a shoe on Moore Street, I'm a prostitute from Newry".

Posted ImagePosted Image


#4
south_cheshire_toon

south_cheshire_toon
  • YTS Contract

  • 108 posts
I know it's not an answer - but a quick goole search gave me the following :-


http://www.regular-e...o/examples.html


http://www.pagecolum...t_html_tags.htm


And each page look like it has good onward links that might help.
The last man alive on the planet, sat, alone, in a room. Suddenly, there was a knock at the door.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users