Bernd VanSkiver wrote: > 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>
A generalized version is below. Well, sort of. It matches all <img> with a src-attribute that does not contain a colon. I can't figure out how to tell it to compare with the full "http://" string, but since a colon is an illegal character in a filename it has to do. Unless you have absolute paths as well (but maybe somebody else can help you then). <cfset string = REReplaceNoCase(string,"(<img[^>]*src="")([^"":]*)(""[^>]*>)", "\1/images/\2\3", "ALL")> Jochem ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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