> I wanted to do (.+?([&?][pq]=([^&]+))?.*?)?$
> but it would never recognise the internal expression that would be the search.

These regexes have several issues, but the root cause of the problem with the 
regex above is that the inner group (intended to capture the search terms) is 
optional. Since the regex will successfully match even when the grouping is 
excluded, it does just that.

As far as improving the full regex's efficiency, you could do:

<cfset qReferer = 
REFindNoCase("^https?://([^/]+)/?([^?]+(?:[?&][pq]=([^&]+)|.)*)?$", referer, 1, 
TRUE)>

Positions:
2 = Domain
3 = Relative URL excluding the leading slash ("referer string")
4 = Search term

On a related note, and as a shameless plug, check out my parseUri UDF for 
splitting any URI: 
http://badassery.blogspot.com/2007/01/parsing-uris-in-coldfusion.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7 
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs 
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1020
Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.21

Reply via email to