2011-08-03 92 views
0

我正在嘗試爲ajax請求寫一個響應過濾器..特別是我正在將.axd調用縮減爲一個緩存的腳本調用。我需要一個正則表達式來返回所有匹配的| 123 | scriptBlock | ScriptPath | ScriptResource.axd?d = blah阿賈克斯過濾器的正則表達式篩選器

下面是我需要匹配的一些文本示例。最終,我需要用空字符串來替換所有這些比賽...所以如果我能在一杆中做到這一點,那就太好了。

Content_ContentPlaceHolderMain_rwSaveSearch_C_RequiredFieldValidator1" )| 202 |腳本塊|了ScriptPath | /MyApp/MyPage/ScriptResource.axd d = 8cuS6HlvJsa1x3tLEcL_TItpBXYm_zmbMr_ctbJmVoYz9JL8P-kaT5M-TlE6yK7pBgANX9zpol_idS8Sj0IaHQ4lC3WfqbZf5Ejr2iWPHH49w-ynh0s-MDLkl3mO8sXuBUHVXEq9Pc5Tv6TRLCyrxy-Qcew1 &噸= 22cb5c6c?| 181 |腳本塊|了ScriptPath |/MyApp的/我的頁面/的ScriptResource.axd d = ntY1JbINTRtcX6DAOm-LUY-o905uosY8Zpy3si1TvH0FdGOGq83-DclzMqazpnh5uHaBK7NlSAMFP9188wUDQKtolKOvgZpY544PewcHdf8qZQV5KXhWiTI1Ee6xcV99Q8xkJQ2 &噸= 55d87db2?| 202 |腳本塊|了ScriptPath |?/MyApp/MyPage/ScriptResource.axd d = B1rz4Fn_O0PKVtdTw68GtiU3bFInY6NFO6aVyAeiMqR5JNa5BexYHVOr2TF0gw_p8sZ8SojGciziipec-Y1dEnpkgv0WNksL2i4_P7ZsnSW-AASVlf-Y1ncJY8AriWp2YfQI6lF-Y0w2zD2ocgRxDrN28581 &噸= 55d87db2 | 202 |腳本塊|了ScriptPath |/MyApp的/邁帕足球俱樂部?GE /的ScriptResource.axd d = Z-wyUCLB7-3WWtK8B2CDVjANFI3YIJe7etu1AsYU5rvwOMmf0zGGkucBfWQiWlBl56QQ8jtOiCllNVEQO9pzFKUdhRtpdAiQSS6OWxqkif0eK1MBY2QhTeSLVjpBlbOu77_jzmLL_Axr-9o6C8pHEtXYnrg1 &噸= 55d87db2 | 223 |腳本塊|了ScriptPath | /MyApp/MyPage/ScriptResource.axd d = _YcNfgF_vWrrR_oicNIXksyqwgv6MBkdHBRWhVOwy-PLmpBMW5DpFQZL6KI8kFkHWY6WnpstMKuOHGETC1y6WzKmSAXOHqaj5GkKmYoiKCXb3qTR_MbDpWdDXmnnlBmSI6b1nLiVAl1XCQD9LOkYQKVvkVHnnAEuxg98HHQ5EwcYxVbQ0 &噸= 55d87db2?| 202 |腳本塊|了ScriptPath ?| /MyApp/MyPage/ScriptResource.axd d = dQRBFe2100Glspd6HHb7vVm05awW9jeer-UK_UFuuTd3FCAEDsRItcEZTZE7_DJwiSyXp5JRbGT3QvNIsWJEPOOL76SiIM4CP827HsdclJhADXKTxDkKa__xneVcnb3uPptO4EoWNkUaOOQEiORd3dPW2401 & T = 55d87db2 | 62 | scriptStartupBlock | ScriptContentNoTags |如果(typeof運算)等等...

+1

哇,文本的聖蝙蝠俠壁。你可能只是列出這些比賽的名單,而不是隻用一個豎條分開它們? – Nightfirecat

回答

0

這種模式應該工作:

\|\d{3}\|scriptBlock\|ScriptPath\|/MyApp/MyPage/ScriptResource\.axd\?d=[^|]* 

在C#,替換碼將是:

string pattern = @"\|\d{3}\|scriptBlock\|ScriptPath\|[^|]*ScriptResource\.axd\?d=[^|]*"; 
string replacement = Regex.Replace(input, pattern, ""); 

施加到上面的字符串,它返回

Content_ContentPlaceHolderMain_rwSaveSearch_C_RequiredFieldValidator1")