Function repnum (strng) 'returns an array
I = 0
Set regex = new regexp
Regex. pattern = "(d +)" '"[0-9]"
Regex. ignorecase = true
Regex. global = true
Set matches = regex.exe cute (strng)
For each match in matches
'Retstr = retstr & "<br>" & match. value
If len (match. value)> = 5 then
Strng = replace (strng, right (match. value, 4 ),"***")
End if
I = I + 1
Next
Repnum = strng
End function
<% = Repnum (content) %> is used directly. The running result is that some numbers in the content string are replaced with *** to hide the contact information. If you think there are more numbers left, change the corresponding number in this function.
Add a related function.
Function: extracts all numbers from a string using the regular expression in the asp tutorial.
Parameter: strng indicates the content to be extracted.
Function regexptest (strng) 'returns an array
I = 0
Set regex = new regexp
Regex. pattern = "(d +)" '"[0-9]"
Regex. ignorecase = true
Regex. global = true
Set matches = regex.exe cute (strng)
For each match in matches
Retstr = retstr & "<br>" & match. value' output the extracted number
I = I + 1
Next
Regexptest = retstr
End function
Usage method <% = regexptest (content) %>. The running result is all the numbers in the content string and the line breaks.