Nobody seems to have replied, so here goes....

You don't want to use (.*) as regexes are greedy and will try to match
the biggest string possible. If you have to <a>s in a block, this regex
will match from the start of one to the end of the other. 

<cfset content=REReplaceNoCase(content, "<a href=""([^ ""]*)
([^""]*)"">", "<a href=""\1%20\2"">", "all")>

This will only replace one space per anchor. You need to run it
repeatedly to get them all.

Regards, 
Matthew Walker 
/* 
        Easier, smarter forms:
        http://www.matthewwalker.net.nz/inform2 
*/ 




> -----Original Message-----
> From: Wallick, Mike [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 24 May 2002 3:24 a.m.
> To: CF-Talk
> Subject: RegExp Help
> 
> 
> Hey all. I'm trying to cook up a regexp to search a block of 
> text for links.
> What I'm looking for is something like:
>  
> <a href="path with spaces/file with spaces.htm">
>  
> I want to read the block of text and replace spaces with %20 
> so links won't
> break. I know, I know, links shouldn't have spaces in them, 
> but this is
> something I inherited and changing all the links and 
> filenames associated
> with them is not an option (there are thousands of links/files).
>  
> I've tried this: <cfset content=REReplaceNoCase(content, '<a 
> href="(.*)">',
> '<a href="#URLEncodedFormat(\1)#">', "all")>
>  
> and this: <cfset content=REReplaceNoCase(content, '<a 
> href="(.*)">', '<a
> href="#Replace(\1, " ", "%20"))#">', "all")>
>  
> and those don't work. Can I not use CFML functions on a 
> regexp subexpression
> (\1) ?
>  
> I'm not exactly an expert on regexps, so any help would be greatly
> appreciated.
>  
> 
>  
> 
> Mike Wallick
> 
> 
> 
> 
> Web Application Developer
> 
> 
> 
> 
> [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]> 
> 
> 
> 
> 
> 651.628.5377
> 
> 
> 
> 
> http://www.securecomputing.com <http://www.securecomputing.com/> 
> 
>  
> 
>  
> 
> 
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
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