简体   繁体   中英

Regular expression - match strings between range

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.

If input string is always a similar UPDATE statement:

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

Live demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM