SoFunction
Updated on 2025-04-06

Asp extracts the regular code of mobile phone number, qq, and URL in the content

Commonly used regular matching expressions

Regular expression-Verify mobile phone number: 13[0-9]{9}
Implement the situation where the mobile phone number is 86 or +86:^((\+86)|(86))?(13)\d{9}$
Verify phone number and mobile phone number simultaneously: (^(\d{3,4}-)?\d{7,8})$|(13[0-9]{9})
Extract the network link in the information: (h|H)(r|R)(e|E)(f|F) *= *('|")?(\w|\\\|/|\.)+('|"| *|>)?
The email address in the extracted information: \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Image link in extracting information: (s|S)(r|R)(c|C) *= *('|")?(\w|\\\|/|\.)+('|"| *|>)?
The IP address in the extract information: (\d+)\.(\d+)\.(\d+)\.(\d+)\.(\d+)
Chinese mobile phone number in the extracted information: (86)*0*13\d{9}
Chinese fixed phone number in the extracted information: (\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}
Extract Chinese phone numbers (including mobile and landline phones) in the information: (\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}
The Chinese postal code in the extracted information: [1-9]{1}(\d+){5}
The Chinese ID number in the extracted information:\d{18}|\d{15}
Extract integers in the information: \d+
Extract floating point numbers (i.e. decimals) in the information: (-?\d*)\.?\d+
Extract any number in the information: (-?\d*)(\.\d+)?
Extract Chinese strings in the information: [\u4e00-\u9fa5]*
Extract the double-byte string (Chinese characters): [^\x00-\xff]*

The function used (the first parameter is a regular expression and the second is a string):
Copy the codeThe code is as follows:

Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variables.
Set regEx = New RegExp ' Create regular expression.
= patrn ' Set mode.
= True ' Set whether characters are case sensitive.
= True ' Set global availability.
Set Matches = (strng) ' Perform a search.
For Each Match in Matches ' traverses the matching collection.
'RetStr = RetStr & "Match found at position "
'RetStr = RetStr & & ". Match Value is '"
RetStr = RetStr &
Next
RegExpTest = RetStr
End Function