A
A
Androgen132018-06-19 09:07:08
Regular Expressions
Androgen13, 2018-06-19 09:07:08

How to use a regular expression to find the next character after the pattern?

There is a SQL script in text format. It is necessary that kind equal to 1 be put down everywhere, i.e. in fact find the numbers following the pattern - (VALUES.*?,.*?,.*?,). In this case, it is 0. Can this be done somehow through regular expressions?
INSERT INTO table(name, dsc, type, kind, n, s, d, def_n, def_s, def_d, change_dt, r_id)
VALUES (N'TEST1',null,4,0,1,null,null,1,null ,null,getdate(),0);
INSERT INTO table(name, dsc, type, kind, n, s, d, def_n, def_s, def_d, change_dt, r_id)
VALUES (N'TEST2',null,1,0,5000,null,null,5000,null ,null,getdate(),0);
INSERT INTO table(name, dsc, type, kind, n, s, d, def_n, def_s, def_d, change_dt, r_id)
VALUES (N'TEST3',null,3,0,null,'ALL',null,null ,'ALL',null,getdate(),0);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Androgen13, 2018-06-19
@Androgen13

I needed to replace in notepad ++, then when adding an asterisk character to the template, the regular expression became invalid. As a result, I made a replacement according to the following pattern - (?<=(\D',null,\d,))\d .

V
vreitech, 2018-06-19
@fzfx

(VALUES.*?,.*?,.*?,)[\ ]?(\d+)
and using the language you are using, get the contents of the first group (we assume that the group with VALUES is zero).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question