This article mainly introduces the method of clearing HTML-specified tags by ASP regular expressions, and tells you how to accurately filter out certain attribute tags and parameters. Interested friends can refer to it.
During the release of HTML editor, some automatically generated HTML tags will appear, or during the application of the message board program, some people will maliciously write some HTML code, so how to accurately filter out certain specific attributes What about labels and parameters? Here is the code:
- <%
- FunctionReplaceText(fString,patrn,replStr)
- SetregEx=NewRegExp' creates a regular expression.
- regEx.Pattern=patrn'Set mode.
- regEx.IgnoreCase=True' Set whether it is case sensitive.
- regEx.Global=True' sets global availability.
- ReplaceText=regEx.Replace(&fString&,&replStr&)' is used as a replacement.
- SetregEx=nothing
- EndFunction
- FunctionMBrow(str)
- str=ReplaceText(str,data-scayt_word=([^]*),) 'Change the blue part attribute to the attribute name you filtered
- str=ReplaceText(str,data-scaytid=([^]*),) 'The red part filters out the quality in the double quotes after the attribute
- MBrow=str
- EndFunction
- %>
This article tells you how to use ASP regular expressions to implement filtering functions and how to use ASP regular expressions to clear HTML specified tags. I hope it will be helpful to everyone's learning.