Use regular expressions to represent strings that do not contain 2950--regular expressions
Source: Internet
Author: User
Use the VBA test in Excel as follows (the match is: ^ (?!) 2950).) *$):
Sub regs ()
Dim RegEx as Object
Set RegEx = CreateObject ("VBScript.RegExp")
Dim S, Mat
s = "399295078"
Regex.pattern = "^ ((?!) 2950).) *$"
Regex.global = True
MsgBox Regex.test (s)
Set RegEx = Nothing
End Sub
If 2950 is matched, the return is false, otherwise true.
of which, (?!) 2950) indicates a mismatch of 2950,
and ^ represents the starting position of the matching string,
. Represents a match for any single character except "\ n".
$ indicates the end position of the matching string.
* indicates that the preceding subexpression was matched 0 or more times.
The whole match is to match a null value or a string that does not contain 2950.
of which (?!) 2950 must be followed by a ".", then (?!) 2950). Indicates that there is no 2950 and at least one character. In fact, the whole is (?!) 2950) and (.) * The combination, (.) * indicates an empty string or any string (does not contain \ n).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.