Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression HELL!!!

Status
Not open for further replies.

KristianW

Programmer
Nov 5, 2003
9
NL
Hey all.

I'm fixing a webpage that uses RE's to convert hyperlinks to become relative to the calling page. However, sometimes the RE simply appends the hyperlink URL to the end of the original URL, so the final link looks like:


This obviously will not work, so I'm creating a new RE to look for this occurrance (as well as mailto and to the end, as this sometimes happens as well). So my RE looks like the following:

Code:
<cfset PageContent=REreplacenocase(PageContent,"(href="")([^\?]*)\?([^(http|www|mailto|"")]*)((http|www|mailto)[^""]+)","\1\4","ALL")>

(all one line)

the first section of the RE ((href="")([^\?]*)\?) should match any hyperlink up to the querystring. The ([^(http|www|mailto|"")]*) section is designed to get zero or more of ANY character, unless it is http, mailto, www, or the closing quote for the hyperlink.

The next section ((http|www|mailto)[^""]+) then searches for data starting with http, mailto, or www, and then any more info up until the closing ". The problem is that this only seems to work some of the time. For example:

gets resolved to which is great. However, the following link is not recognised (I'm assuming this, as it is not being changed)


From what I can tell, there is nothing wrong with my RE (but then again my eyes are losing focus right now...) Shouldn't the ([^(http|www|mailto|"")]*) section return EVERYTHING other than what is in the square brackets? Ie, it should catch anything, or nothing, and then keep going, as long as it isn't http, www, mailto or the closing "

Can anyone help me with this? I just can't understand why it's not happening....

Cheers,
K.
 
just a suggestion (don't double post yet) if we can't help you, the JS guys use Regex a lot they maybe able to help you.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top