Avoid regex to capture contents of string (between quotes) -


i'm using following regex capture array of string follows conditions (e.g.: it's not prepended letter or number, , contains strings surrounded single or double quotes):

/^?[ =>]\[(('|")[^('|")\s]*('|")(, ?)?)+\]/ 

it should capture

["bla", "ble", "blo"] 

however, should not capture that, if it's part of string between (single or double) quotes:

'["bla", "ble", "blo"]' 

what should add avoid capturing unwanted case?

add negative lookbehind/lookahead expression pattern:

(?<!['])(?!['])(\[(('|")[^('|")\s]*('|")(, ?)?)+\])

worked me when testing, may depend on regex engine.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -