House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

RegEx: Grabbing Keywords from Referers

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

RegEx: Grabbing Keywords from Referers

Thanks for the update Peter. Che Vilnonis 08/24/2010 08:45 AM
><cfset keywords = reMatchNoCase("[?|&][p|q]=[^&]+", referer)> Peter Boughton 08/24/2010 05:06 AM
Awesome Che! Glad I could be of help! Andy Matthews 08/23/2010 04:14 PM
Andy thanks again so much... this seems to work with Yahoo,Bing & Google. Che Vilnonis 08/23/2010 04:02 PM
Wow. That works very well. Thanks! Che Vilnonis 08/23/2010 03:42 PM
Ah. The text was so small in my testing app that I couldn't tell what that Andy Matthews 08/23/2010 02:55 PM
> Not sure where the second q= came from. John M Bliss 08/23/2010 02:48 PM
This regex would search through a string and return all occurences of Andy Matthews 08/23/2010 02:45 PM
> I wonder if the regex gurus have a solution as well. John M Bliss 08/23/2010 02:38 PM
Nice solution John. Thanks! Definitely different than mine. Che Vilnonis 08/23/2010 02:34 PM

08/24/2010 08:45 AM
Author: Che Vilnonis Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336491 Thanks for the update Peter. ><cfset keywords = reMatchNoCase("[?|&][p|q]=[^&]+", referer)> This is incorrect - the | is a literal in character classes. You want [?&][pq]=[^&]+
08/24/2010 05:06 AM
Author: Peter Boughton Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336489 ><cfset keywords = reMatchNoCase("[?|&][p|q]=[^&]+", referer)> This is incorrect - the | is a literal in character classes. You want [?&][pq]=[^&]+
08/23/2010 04:14 PM
Author: Andy Matthews Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336482 Awesome Che! Glad I could be of help! andy Andy thanks again so much... this seems to work with Yahoo,Bing & Google. My RegEx skills are a work in progress. <cfset referer = "http://search.yahoo.com/search;_ylt=Aqj24Omsi1LGKlDY4_G1hi6bvZx4?fr=yfp-t-7 01-s&toggle=1&cop=mss&ei=UTF8&p=children%20karate%20uniform"> <cfset keywords = reMatchNoCase("[?|&][p|q]=[^&]+", referer)> <cfset keywords = urlDecode(reReplace(keywords[1],"[?|&][p|q]=", "","ALL"))>
08/23/2010 04:02 PM
Author: Che Vilnonis Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336481 Andy thanks again so much... this seems to work with Yahoo,Bing & Google. My RegEx skills are a work in progress. <cfset referer = "http://search.yahoo.com/search;_ylt=Aqj24Omsi1LGKlDY4_G1hi6bvZx4?fr=yfp-t-7 01-s&toggle=1&cop=mss&ei=UTF8&p=children%20karate%20uniform"> <cfset keywords = reMatchNoCase("[?|&][p|q]=[^&]+", referer)> <cfset keywords = urlDecode(reReplace(keywords[1],"[?|&][p|q]=", "","ALL"))>
08/23/2010 03:42 PM
Author: Che Vilnonis Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336480 Wow. That works very well. Thanks! Ah. The text was so small in my testing app that I couldn't tell what that was. Try this instead: [?|&]q=[^&]+ That only looks for q= when immediately following a ? or an &. Given the same string: http://www.google.com/search?q=coldfusion&source=ig&hl=en&rlz=&aq=f&aqi=g-p3 g7&aql=&oq=&gs_rfai=CJtNhsL9yTK_zHIWWhgTb-J3tDwAAAKoEBU_QXcSj It only matches ?q=coldfusion or &q=coldfusion > Not sure where the second q= came from. >From this:  &aq=f& On Mon, Aug 23, 2010 at 1:44 PM, Andy Matthews <lists@commadelimited.com>wrote: ----- Excess quoted text cut - see Original Post for more -----
08/23/2010 02:55 PM
Author: Andy Matthews Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336476 Ah. The text was so small in my testing app that I couldn't tell what that was. Try this instead: [?|&]q=[^&]+ That only looks for q= when immediately following a ? or an &. Given the same string: http://www.google.com/search?q=coldfusion&source=ig&hl=en&rlz=&aq=f&aqi=g-p3 g7&aql=&oq=&gs_rfai=CJtNhsL9yTK_zHIWWhgTb-J3tDwAAAKoEBU_QXcSj It only matches ?q=coldfusion or &q=coldfusion > Not sure where the second q= came from. From this:  &aq=f& On Mon, Aug 23, 2010 at 1:44 PM, Andy Matthews <lists@commadelimited.com>wrote: ----- Excess quoted text cut - see Original Post for more -----
08/23/2010 02:48 PM
Author: John M Bliss Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336475 > Not sure where the second q= came from. From this:  &aq=f& On Mon, Aug 23, 2010 at 1:44 PM, Andy Matthews <lists@commadelimited.com>wrote: ----- Excess quoted text cut - see Original Post for more -----
08/23/2010 02:45 PM
Author: Andy Matthews Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336474 This regex would search through a string and return all occurences of q=followed by any character that's NOT an &. q=[^&]+ Given this string: http://www.google.com/search?source=ig&hl=en&rlz=&q=coldfusion&aq=f&aqi=g-p3 g7&aql=&oq=&gs_rfai=CJtNhsL9yTK_zHIWWhgTb-J3tDwAAAKoEBU_QXcSj It matches q=coldfusion q=f Not sure where the second q= came from. I just did a search on the Google homepage for "ColdFusion". andy Nice solution John. Thanks! Definitely different than mine. I wonder if the regex gurus have a solution as well. ;) This does (at least) Google.  Shouldn't be too difficult to extrapolate the others... <cfloop index="thisarg" list="#cgi.HTTP_REFERER#" delimiters="?&">    <cfif ListFirst(thisarg, "=") is "q" and ListLen(thisarg, "=") is 2>       <!--- then user searched for URLDecode(ListLast(thisarg, '=')) --->       <cfbreak>    </cfif> </cfloop>
08/23/2010 02:38 PM
Author: John M Bliss Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336473 > I wonder if the regex gurus have a solution as well. Oh, I'm sure.  :-) ----- Excess quoted text cut - see Original Post for more -----
08/23/2010 02:34 PM
Author: Che Vilnonis Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61830#336472 Nice solution John. Thanks! Definitely different than mine. I wonder if the regex gurus have a solution as well. ;) This does (at least) Google.  Shouldn't be too difficult to extrapolate the others... <cfloop index="thisarg" list="#cgi.HTTP_REFERER#" delimiters="?&">    <cfif ListFirst(thisarg, "=") is "q" and ListLen(thisarg, "=") is 2>       <!--- then user searched for URLDecode(ListLast(thisarg, '=')) --->       <cfbreak>    </cfif> </cfloop> > > I'm looking for a script to parse (yahoo,bing,google) keywords from > the cgi.http_referer variable preferrably done using CF's or a Java RegEx. > > Is there such a beast? > > TIA, Che
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference