开发者

Regex filter for ajax filter

I'm trying to write a response filter for ajax requests..specifically I'm minifying the .axd calls into one cached script call. I need a regex expression that will return me all of the matches for |123|scriptBlock|ScriptPath|ScriptResource.axd?d=blah

Here is some example of the text that I need to match on. Ultimately开发者_如何学C I need to replace all those matches with an empty string...so if I could do that in one shot that would be great.

Content_ContentPlaceHolderMain_rwSaveSearch_C_RequiredFieldValidator1")|202|scriptBlock|ScriptPath|/MyApp/MyPage/ScriptResource.axd?d=8cuS6HlvJsa1x3tLEcL_TItpBXYm_zmbMr_ctbJmVoYz9JL8P-kaT5M-TlE6yK7pBgANX9zpol_idS8Sj0IaHQ4lC3WfqbZf5Ejr2iWPHH49w-ynh0s-MDLkl3mO8sXuBUHVXEq9Pc5Tv6TRLCyrxy-Qcew1&t=22cb5c6c|181|scriptBlock|ScriptPath|/MyApp/MyPage/ScriptResource.axd?d=ntY1JbINTRtcX6DAOm-lUy-o905uosY8Zpy3si1TvH0FdGOGq83-DclzMqazpnh5uHaBK7NlSAMFP9188wUDQKtolKOvgZpY544PewcHdf8qZQV5KXhWiTI1Ee6xcV99Q8xkJQ2&t=55d87db2|202|scriptBlock|ScriptPath|/MyApp/MyPage/ScriptResource.axd?d=B1rz4Fn_O0PKVtdTw68GtiU3bFInY6NFO6aVyAeiMqR5JNa5BexYHVOr2TF0gw_p8sZ8SojGciziipec-Y1dEnpkgv0WNksL2i4_P7ZsnSW-AASVlf-Y1ncJY8AriWp2YfQI6lF-Y0w2zD2ocgRxDrN28581&t=55d87db2|202|scriptBlock|ScriptPath|/MyApp/MyPage/ScriptResource.axd?d=z-wyUCLB7-3WWtK8B2CDVjANFI3YIJe7etu1AsYU5rvwOMmf0zGGkucBfWQiWlBl56QQ8jtOiCllNVEQO9pzFKUdhRtpdAiQSS6OWxqkif0eK1MBY2QhTeSLVjpBlbOu77_jzmLL_Axr-9o6C8pHEtXYnrg1&t=55d87db2|223|scriptBlock|ScriptPath|/MyApp/MyPage/ScriptResource.axd?d=_YcNfgF_vWrrR_oicNIXksyqwgv6MBkdHBRWhVOwy-PLmpBMW5DpFQZL6KI8kFkHWY6WnpstMKuOHGETC1y6WzKmSAXOHqaj5GkKmYoiKCXb3qTR_MbDpWdDXmnnlBmSI6b1nLiVAl1XCQD9LOkYQKVvkVHnnAEuxg98HHQ5EwcYxVbQ0&t=55d87db2|202|scriptBlock|ScriptPath|/MyApp/MyPage/ScriptResource.axd?d=dQRBFe2100Glspd6HHb7vVm05awW9jeer-UK_UFuuTd3FCAEDsRItcEZTZE7_DJwiSyXp5JRbGT3QvNIsWJEPOOL76SiIM4CP827HsdclJhADXKTxDkKa__xneVcnb3uPptO4EoWNkUaOOQEiORd3dPW2401&t=55d87db2|62|scriptStartupBlock|ScriptContentNoTags|if(typeof) blah...


This pattern should work:

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

In C#, the replacement code would be:

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

Applied to the above string, this returns

Content_ContentPlaceHolderMain_rwSaveSearch_C_RequiredFieldValidator1")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜