>- see footer for list info -<
Thanks for that, Peter.

I tested it and it worked ok on the second url but left &oq= (empty
variable value) on the first one. Regex seems extremely powerful but
difficult to get exactly what you need.



So, I though it maybe easier to alter the way I search for q= in the url, 
rather than
remove what i didn't want.



<cfset startpos = ReFindNoCase("[\?|&]q=.",myref)>
<cfset endpos = mid(myref,startpos+3,Len(myref))> (3 is &q= or ?q=)
<cfset keywords = ReReplaceNoCase(endpos,'&.*','','all')>
<cfset keywords = URLDecode(Keywords)>

Time to get a decent Regex book i reckon.

--- On Mon, 20/7/09, Peter Boughton <[email protected]> wrote:

From: Peter Boughton <[email protected]>
Subject: Re: [CF-Dev] Regular Expression Help
To: "Coldfusion Development" <[email protected]>
Date: Monday, 20 July, 2009, 12:10 PM

>- see footer for list info -<
Try this:

<cfset myref = myref.replaceAll( '(?<=[&?])[a-z]+q=[^&]++&?' , '' ) />

That's using Java regex (the string.replaceAll func) since regular
CFML regex doesn't support lookbehinds - will work in all regex
engines that run on Java.


And to explain that regex, here's it disected in comment mode:
(?x)       # enable regex comment mode
(?<=[&?])  # start with either & or ? but don't include in match
[a-z]+q=   # one or more a-z followed by q=
[^&]++     # possessively match any non-ampersand
&?         # optionally match ampersand to avoid result having ?& or
&& after replace.


All make sense?

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<




_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to