I have this string:
Parameter1="Something related to this" Parameter2="Another value" Parameter3='Single quotes are permitted' Parameter4="Even HTML entities are permitted"
I want to get this list:
I tried this regex. But it's not working:
(\w+)=(('|"|")).*(('|"|"))
How can I parse this string and extract key-value pairs?
You can use
(\w+)=(['"]|")(.*?)\2
See the regex demo . Details :
(\w+)
- Group 1: one or more word chars =
- an equals sign (['"]|")
- Group 2: '
, "
or "
(.*?)
- Group 3: any zero or more chars other than an LF char as few as possible \2
- Group 2 value.
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.