1

I am using the this regular expression to find all occurrences of INT IDENTITY (1, 1) NOT NULL:

\bINT\s*IDENTITY\s*\(1,\s*1\)\s*NOT\s*NULL\b

A sample of where it is in the whole context is something like:

CREATE TABLE table1 (
    [col]                INT      IDENTITY (1, 1) NOT NULL,
    [col2]               INT      NOT NULL,
    [col3]               BIT      NOT NULL,
    [col4]               BIT      NOT NULL,
    [col5]               DATETIME NOT NULL,
    PRIMARY KEY CLUSTERED ([col] ASC) WITH (FILLFACTOR = 90, ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF)
);

But the regular expression above does not find anything. When I try it online using Rubular, Gskinner, or Regex Hero, it works.

3 Answers 3

2

Visual Studio has its own specific regex flavour - for example there is no \b (for word boundary, I presume), so using it will not work.

I suggest reading up on Regular Expressions (Visual Studio) 2010 / 2012 for the syntax.

Sign up to request clarification or add additional context in comments.

3 Comments

The question is tagged with Visual Studio 2010. The reference describes Visual Studio 2012 (at least as of today), not Visual Studio 2010: "In Visual Studio 2010 and earlier versions, Visual Studio used custom regular expression syntax in the Find and Replace windows. "
@PeterMortensen - Thanks for the correction and link. Answer updated.
2

Try this one:

:b+INT:b+IDENTITY:b+(1,:b*1):b+NOT:b+NULL

2 Comments

This was close, but I believe you need to escape the ( and ) characters or it treats it as a group.
@Xaisoft good to know. I didn't test it much I was hoping he would run with that.
1

I ended up using the following expression:

INT:b+IDENTITY:b+\(1,:b*1\):b+NOT:bNULL

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.