javascript - Recursive regular expression in ruby -
i have script open request server , gets javascript output.
this output looks this:
html = new array();mark = new array();html.push('html tags(something want)more html');mark.push(new obj(-12.1231231, -12.12312312312));html.push('html tags(something want)more html');mark.push(new obj(-12.1231231, -12.12312312312));html.push('html tags(something want)more html');mark.push(new obj(-12.1231231, -12.12312312312));html.push('html tags(something want)more html');mark.push(new obj(-12.1231231, -12.12312312312));html.push('html tags(something want)more html');mark.push(new obj(-12.1231231, -12.12312312312));otherstuf.idontcare(new object(-16.630495852614, -49.264667191591), 13);
i want create regular expression take in: (something want)
, numbers on new obj(-12.1231231, -12.12312312312)
, in part:
html.push('html tags(something want)more html');mark.push(new obj(-12.1231231, -12.12312312312))
i want only:
(something want) -12.1231231 -12.12312312312
but every place find this.
i created regex take inner content
/^html = new array\(\);mark = new array\(\);(.*)otherstuf.idontcare\(new object\([\+\-\.0-9]*, [\+\-\.0-9]*\), [\d]*\);$/
but i'm kinda of stuck. cant see way of taking info need.
how can this?
gist regexp , example of javascript need parse: https://gist.github.com/nicoskaralis/5571240
a single regex can't handle want want.
i recommend first split blocks , run regex on each of them:
output.split(/html\.push/).each |block| # grab "something want" , numbers in block end
Comments
Post a Comment