Martin
Martin

Reputation: 3

Regular expression to replace value of ID field in mysql insert query

I need to change the ID of the following script with a regular expression in notepad++.

Example:

Insert into AAAAA
   (ID, A, B, C)
 Values
   (1234, dasdas, fdasdsa, FSD);

After regular expresion:

Insert into AAAAA
   (ID, A, B, C)
 Values
   (sequence, dasdas, fdasdsa, FSD);

Upvotes: 0

Views: 513

Answers (2)

adarshr
adarshr

Reputation: 62593

I don't have Notepad++ here but this may work:

replace

(.*Values \()(\d+)(.* ) with

\1sequence\3

Upvotes: 0

Tim
Tim

Reputation: 14154

When you face this kind of problem, you should start by explaining (to yourself) how one could identify the ID part. To write the regular expression, you must first formulate necessary and sufficient conditions for actually finding the string. Also, explaining them would make it a lot easier to help you, since we would not be guessing what is variable in your example.

The ID seems to be the only number that follows an opening bracket. A matching regular expression would be:

/\(\d+/

To replace with:

(sequence

Upvotes: 2

Related Questions