• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Regex Issue

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to parse some text using JavaScript which has sections like this:



I want to obtain the "something_here" out of that string. To do that, I wrote this regex:



My hope was that this would match any text that follows id10.val" and match any text it found until another " was reached. The problem is that it's very possible for there to be another " somewhere else in this string. When that happens, my regex doesn't match just what id10.val refers to but everything in the String up to the final ".

Is there any way to get around this? Basically, I want to get all text up to the first " but no more.

Thanks.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you could use eval() and turn that string into working JavaScript code. You would have to make sure you have an object named id10.



Now if you still want to go the regular expression route:



Now that will fail if there is an escaped \" inside of there.

Eric
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic