0

I have a string which looks like this:

UPDATE id = :id, password = :password;

I want to match this string:

id = :id, password = :password

I wrote this regexp:

UPDATE\s(\S+\s*=\s*\S+)\s

but it matches only

id = :id,

I tried also this regexp:

UPDATE\s(\S+\s*=\s*\S+)\s;

but it cannot recognize a range what I want to match

How I have to define range in the right way to match that what I want?

I will be grateful for any advice.

1
  • I want to match whole string which looks like this "value = :value, test=:value2" from any string, spaces must be allowed. Commented Aug 19, 2016 at 6:17

1 Answer 1

1

If input string is always a similar UPDATE statement:

UPDATE\s*\K|([^;]+)

Live demo

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

3 Comments

What if I want to match: " value = :value, test=:value2" from this string: "INSERT INTO table (value, value1) VALUES (:value1, :value2,) ON DUPLICATE KEY UPDATE value = :value, test=:value2;" ?
I figured out how to make this. This regexp resolve my problem: UPDATE\s(.+,*?);
Just remove the alternation UPDATE\s*\K([^;]+) @MateuszRavage

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.