Use a regular expression to indicate a string that does not contain 2950

Source: Internet
Author: User

Use VBA in Excel to test the following (matching formula: ^ ((?! 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, false is returned; otherwise, true is returned.
Where ,(?! 2950) does not match 2950,
^ Indicates the starting position of the matching string,
. Match any single character except "\ n,
$ Indicates the end position of the matched string,
* Indicates matching the previous subexpression zero or multiple times.
The entire matching formula is: match a null value or match a string without 2950.
Where (?! 2950) must be followed by a ".", then (?! 2950). It does not contain 2950 characters and must contain at least one character. In fact, the whole is (?! 2950) and (.) *, (.) * indicates an empty string or any other string (excluding \ n ).

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.