Problem with Regex Replacement
Posted: Mon Aug 18, 2008 7:02 pm
Here is the regex find:
Here is the replacement string:
Sample Target String:
Here is sample output in TextPad:
Here is sample output from Regex Coach:
Regex Coach is producing the desired and expected behavior, based on my understanding of regex replacement. I am completely at a loss as to what is happening in TextPad. It appears that TP is interpreting the "\1" to be the entire beginning of the string, rather than the first capture string. Hopefully, someone can point out a fix.
Thanks.
mp
Code: Select all
GET /mydomain/MYHome.html \(.*\) \([0-9]+ .* .* .* .* .*www.google.com/search\?q=.* .*\)
Code: Select all
GET /mydomain/MYHome.html WT.mc_id=1234&\1 \2
Code: Select all
GET /mydomain/MYHome.html WT.vt_f_tlv=0&WT.tz=-5&WT.bh=2&WT.ul=en-us&WT.cd=32&WT.sr=1024x768&WT.jo=Yes&WT.ti=mydomain,%20Home%20of%20mydomain&WT.js=Yes&WT.jv=1.3&WT.ct=unknown&WT.bs=unknown&WT.fv=9.0&WT.slv=Not%20enabled&WT.tv=8.5.0&WT.dl=0&WT.ssl=0&WT.es=www.mydomain.com/mydomain/MYHome.html&WT.vt_f_tlh=0&WT.vt_f_d=1&WT.vt_f_s=1&WT.vt_f_a=1&WT.vt_f=1&WT.co_d=71.164.135.32-401865200.29948800&WT.vt_tlh=0&WT.co_a=71.164.135.32-401865200.29948800&WT.vt_tlv=0&WT.co=Yes&WT.vt_s=1&WT.vt_d=1&WT.vt_a_s=1&WT.vt_a_d=1&WT.vt_sid=71.164.135.32-399645200.29948800.1218438093747&WT.co_f=71.164.135.32-399645200.29948800 200 - - Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+SLCC1;+.NET+CLR+2.0.50727;+Media+Center+PC+5.0;+.NET+CLR+3.0.04506;+MEGAUPLOAD+2.0) - http://www.google.com/search?q=mydomain&rls=com.microsoft:*:IE-SearchBox&ie=UTF-8&oe=UTF-8&sourceid=ie7&rlz=1I7DKUS dcsi63sbk10000spqr4fuho2j_5f6t
Code: Select all
GET /mydomain/MYHome.html WT.mc_id=1234GET /mydomain/MBHome.html WT.tz=-7&WT.bh=0&WT.ul=en-us&WT.cd=32&WT.sr=1280x800&WT.jo=Yes&WT.ti=mydomain%20Home%20of%20mydomain&WT.js=Yes&WT.jv=1.3&WT.ct=unknown&WT.bs=unknown&WT.fv=9.0&WT.slv=Not%20enabled&WT.tv=8.5.0&WT.dl=0&WT.ssl=0&WT.es=www.mbusa.com/mydomain/MBHome.html&WT.vt_f_tlh=1218438324&WT.vt_tlh=1218438326&WT.co=Yes&WT.vt_sid=68.229.21.141-2148327088.29948797.1218436980993&WT.co_f=68.229.21.141-2148327088.29948797 200 - - Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+SLCC1;+.NET+CLR+2.0.50727;+Media+Center+PC+5.0;+.NET+CLR+3.0.04506) WEBTRENDS_ID=68.229.21.141-2153607088.29948797;+WT_ACCT=68.229.21.141-2153607088.29948797 http://www.google.com/search?q=mydomain&rls=com.microsoft:*:IE-Address&ie=UTF-8&oe=UTF-8&sourceid=ie7&rlz=1I7DKUS dcsi63sbk10000spqr4fuho2j_5f6tWT.tz=-7&WT.bh=0&WT.ul=en-us&WT.cd=32&WT.sr=1280x800&WT.jo=Yes&WT.ti=mydomain-%20Home%20of%20mydomain&WT.js=Yes&WT.jv=1.3&WT.ct=unknown&WT.bs=unknown&WT.fv=9.0&WT.slv=Not%20enabled&WT.tv=8.5.0&WT.dl=0&WT.ssl=0&WT.es=www.mbusa.com/mydomain/MBHome.html&WT.vt_f_tlh=1218438324&WT.vt_tlh=1218438326&WT.co=Yes&WT.vt_sid=68.229.21.141-2148327088.29948797.1218436980993&WT.co_f=68.229.21.141-2148327088.29948797 200 - - Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+SLCC1;+.NET+CLR+2.0.50727;+Media+Center+PC+5.0;+.NET+CLR+3.0.04506) WEBTRENDS_ID=68.229.21.141-2153607088.29948797;+WT_ACCT=68.229.21.141-2153607088.29948797 http://www.google.com/search?q=mydomain&rls=com.microsoft:*:IE-Address&ie=UTF-8&oe=UTF-8&sourceid=ie7&rlz=1I7DKUS dcsi63sbk10000spqr4fuho2j_5f6t
Code: Select all
GET /mydomain/MYHome.html WT.mc_id=1234&WT.vt_f_tlv=0&WT.tz=-5&WT.bh=2&WT.ul=en-us&WT.cd=32&WT.sr=1024x768&WT.jo=Yes&WT.ti=mydomain%20Home%20of%20mydomain&WT.js=Yes&WT.jv=1.3&WT.ct=unknown&WT.bs=unknown&WT.fv=9.0&WT.slv=Not%20enabled&WT.tv=8.5.0&WT.dl=0&WT.ssl=0&WT.es=www.mbusa.com/mydomain/MBHome.html&WT.vt_f_tlh=0&WT.vt_f_d=1&WT.vt_f_s=1&WT.vt_f_a=1&WT.vt_f=1&WT.co_d=71.164.135.32-401865200.29948800&WT.vt_tlh=0&WT.co_a=71.164.135.32-401865200.29948800&WT.vt_tlv=0&WT.co=Yes&WT.vt_s=1&WT.vt_d=1&WT.vt_a_s=1&WT.vt_a_d=1&WT.vt_sid=71.164.135.32-399645200.29948800.1218438093747&WT.co_f=71.164.135.32-399645200.29948800 200 - - Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.0;+SLCC1;+.NET+CLR+2.0.50727;+Media+Center+PC+5.0;+.NET+CLR+3.0.04506;+MEGAUPLOAD+2.0) - http://www.google.com/search?q=mydomain&rls=com.microsoft:*:IE-SearchBox&ie=UTF-8&oe=UTF-8&sourceid=ie7&rlz=1I7DKUS dcsi63sbk10000spqr4fuho2j_5f6t
Thanks.
mp