Common Regular Expression
Regular Expression -- verify mobile phone number: 13 [0-9] {9}
If the mobile phone number is 86 or + 86 before it is implemented: ^ (\ + 86) | (86 ))? (13) \ d {9} $
Verify the phone number and phone number at the same time: (^ (\ 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 | \/| \.) + ('| "| * |> )?
Email Address in the extracted information: \ w + ([-+.] \ w +) * @ \ w + ([-.] \ w + )*\. \ w + ([-.] \ w + )*
Extract the image link in the information: (s | S) (r | R) (c | C) * = * ('| ")? (\ W | \/| \.) + ('| "| * |> )?
Extract the IP address in the information: (\ d +) \. (\ d +)
Extract the Chinese mobile phone number from the information: (86) * 0*13 \ d {9}
Extracted Chinese landline numbers from the information: (\ d {3, 4} \) | \ d {3, 4}-| \ s )? \ D {8}
Extract Chinese phone numbers (including mobile and landline phones) from the Information: (\ d {3, 4} \) | \ d {3, 4}-| \ s )? \ D {7, 14}
Extracted Chinese zip code: [1-9] {1} (\ d +) {5}
Chinese ID card number in the extracted information: \ d {18} | \ d {15}
Extract the integer \ d + from the information.
Extract floating point numbers (decimal places) in the Information ):(-? \ D *)\.? \ D +
Extract any number from the information :(-? \ D *) (\. \ d + )?
Extract the Chinese string from the information: [\ u4e00-\ u9fa5] *
Double-byte string (Chinese character) in the extracted information: [^ \ x00-\ xff] *
Function used (the first parameter is a regular expression and the second parameter is a string ):
Copy codeThe Code is as follows:
Function RegExpTest (patrn, strng)
Dim regEx, Match, Matches 'to create a variable.
Set regEx = New RegExp 'to create a regular expression.
RegEx. Pattern = patrn 'setting mode.
RegEx. IgnoreCase = true' specifies whether the characters are case sensitive.
RegEx. Global = true' to set Global availability.
Set Matches = regEx. Execute (strng) 'to Execute the search.
For Each Match in Matches 'traverses the matching set.
'Retstr = RetStr & "Match found at position"
'Retstr = RetStr & Match. FirstIndex & ". Match Value is '"
RetStr = RetStr & Match. Value
Next
RegExpTest = RetStr
End Function