Recently I have written a program to consider the uncertainty of the information to be filtered, decide to use regular expression to solve it. These two days really learned the regular expression, nearly two days. Learning, this function is basically able to achieve hope, and it is recommended to help have a friend who needs to have friends. Of course, this function is still in a place, I hope that all friends will be given to correct, thank you! ! !
'--- Function Name: SDKSTR ---' - Parameters: TSTR (String to filter) --- '- function: Filter, Email, URL ---'-- Power By SD Web: www.fanzny.com ---'--- QQ: 61192909 mail: fanzny@21cn.com ---' - "Establishment time: 05-03-22 --- 'When this function is reproduced Please keep this information --- function SdkStr (tStr) on error resume next if Trim (tStr) = "" or IsNull (tStr) = true then SdkStr = "" exit function end if response.write "
Before processed: "& TSTR DIM SLIST, DLIST, I, S, regex slist =" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | _ | / |. | & | @ | A | b | c | d | e | f | g | h | i | j | k | l | m | n | o | P | q | r | s | t | u | v | w | X | y | z "dlist =" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | | | & | @ | a | b | C | D | e | f | g | h | i | j | k | L | M | N | o | P | q | r | s | t | u | v | w | x | y | z "s = Ubound (Split, "|")) 'Filter uppercase characters for lowercase characters for i = 0 to s TSTR = Replace (TSTR, Split (Slist, "|") (i), split (dlist, "|") (i)) Next
Set regex = new regexp regex.pattern = "(/ (/ d {2, 4} /) | (/ d {3, 4} -?)) / D {7, 8} | / d {7,8} | 0? 13 / d {1} / d {8} | ((/ w) | [-] | [.]) @ ((/ W) | [-]) [.]) [AZ ] {2,4} | http: ([/ w -] /.) [/ W -] (// [/ w-. ///%% = ]* )? ([/W- ] /.) [/ w -] (// [/ w-. // /%% =】 "" Handling Phone Number and Email, URL Regex.global = True Regex.global = TRUE SdkStr = RegEx.Replace (tStr, "") after Set RegEx = NothingEnd Functionresponse.write "
processing:" & SdkStr ( "t1 www.163.com t2 xxx@126.com t3 020-12345678 test ")