2

With a regex I want comment out constraint by matching 'CONSTRAINT ... ( ))' and replacing it with '\*CONSTRAINT ... ( ))*\'. Operator . * in notepad++ matches the whole document so I cannot use it.

I was thinking of something like the following however some modifications are needed:

CONSTRAINT[\w\s]*\)\)

Input:

    modified_date datetime NULL,
    etl_id int NULL,
    etl_date smalldatetime NULL,
 CONSTRAINT PK_WORK PRIMARY KEY CLUSTERED 
(
    work_id ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) 
) 

Thanks

HamZa
  • 13,530
  • 11
  • 51
  • 70
martez
  • 107
  • 1
  • 10

2 Answers2

1

I'd do :

search for : (,\s*CONSTRAINT.+?\)\s+\))
replace by : /*$1*/

I haven't the english version of Notepad++, but I think the labels are OK.

Verify that regex is selected and also . includes \n

Toto
  • 83,193
  • 59
  • 77
  • 109
0

You need to make your regex non-greedy:

 CONSTRAINT\([^)]+\)\)
Bohemian
  • 365,064
  • 84
  • 522
  • 658