Wednesday 15 January 2014

vba - Regex - match between 1st and last occurrence of double square brackets -



vba - Regex - match between 1st and last occurrence of double square brackets -

i'm looking match text , non text values, located within " " , between 1st , lastly instance of [[ , ]]

window.google.ac.h(["text",[["text1",0],["text2",0,[3]],["text3",0],["text4",0,[3]],["text5",0],["text6",0],["text7",0 ]],{"q":"hygjgjhbjh","k":1}])

so far i've managed results (far ideal) using: "(.*?)",0 issue have either matches way until

"text4",0,[3]]

or starts matching @

["text",

i need match text1 text2 text3 .. text7

notes: double square bracket position , nr of instances, between 1st , lastly not consistent.

thanks help guys!

edit: i'm using http://regexr.com/ test it

well, didn't language, using .net regex (which largely follows perl standard), first match groups of matches of global match using next regex contain values want:

(?<=\[\[.*)"(.+?)"(?=.*\]\])

a global match on "(.+?)" lone homecoming matches first match groups contain characters between quotes. lookbehind assertion (?<=\[\[.*) tells include cases there [[ anywhere behind, i.e. after first instance of [[. similarly, lookahead assertion (?=.*\]\]) tells include cases there ]] anywhere ahead, i.e. before lastly instance of ]].

i tested using powershell. exact syntax global match , extract first match groups of results depend on language.

regex vba excel-vba

No comments:

Post a Comment