简体   繁体   中英

Need to match from json only values with quotes using regex

I'm trying to match all values from any json. My regex right now is /: ('|").*?('|")(?=,)?/g I need to get only value with qoutes, but getting colon also. https://www.regextester.com/99141 Any tips?

Took some doing, but I think this seems to pass the tests I've thrown at it :

/("[^"\\]*(?:\\.[^"\\]*)*")(?=,|\s*(]|}))/g

It appears workable on both minified and prettified JSON strings.

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