why use regular expressions?

try:

<cfif NOT string CONTAINS "http:">
        <cfset string = replaceNoCase(string,"src=""","src=""/images/")>
</cfif>

of if you can't use IF statements for some reason:

<cfset string = replaceNoCase(string,"src=""","src=""/images/")>
<cfset string = replaceNoCase(string,"src=""/images/http","src=""http")>

+-----------------------------------------------+
Bryan Love
  Macromedia Certified Professional
  Internet Application Developer
  Database Analyst
Telecomunication Systems
[EMAIL PROTECTED]
+-----------------------------------------------+

"...'If there must be trouble, let it be in my day, that my child may have
peace'..."
        - Thomas Paine, The American Crisis



-----Original Message-----
From: Bernd VanSkiver [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 13, 2001 2:21 PM
To: CF-Talk
Subject: RegEx Help


Got a Regular Expression problem that I can't figure out how to solve.
Below are two possible strings that could be send to my replace function.
The order of the atributes could be in any order and the domain name and
file name will also be different in each case.

<IMG alt="" src="aboutuson.jpg" border=0>
<IMG alt="" src="http://www.domain.com/aboutuson.jpg"; border=0>

What I need to do is files that don't have a absolute web path with the
"http://"; need something like the following prepended to them: "/images/" so
the results of the above would be as follows.

<IMG alt="" src="/images/aboutuson.jpg" border=0>
<IMG alt="" src="http://www.domain.com/aboutuson.jpg"; border=0>

Here is the regular expression that I was using, but it doesn't work right.

REReplace('<IMG alt="" src="aboutuson.jpg" border=0>',
"src=#Chr(34)#[^http://]";, "src=#Chr(34)#/images/", "ALL")

What I get when I do that is as follows:

<IMG alt="" src="/images/boutuson.jpg" border=0>

It is stripping the first letter off the file name.  Does anyone have an
idea how I can get this to work correctly?  I can't figure out the correct
syntax to get it to do what I want.

Bernd VanSkiver
[EMAIL PROTECTED]
ColdFusion Developer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to