0

I am using a positive lookahead regex to get the matched string, but it gives me Syntax error in regular expression in IE8 what am I doing wrong. I want to match the very 1st occurrence.

Matching input

<IMG title="Configuration older than 90 days" alt=true src="http://indwdev:6130/include/images/expired.png"><IMG title="Converted configuration" alt=true src="http://indwdev:6130/include/images/convert.png">

My regex str.match(/(?<=Converted configuration" alt=)[\w]+(?=)/)

Here is a jsfiddle link.

AabinGunz
  • 12,109
  • 54
  • 146
  • 218
  • 2
    Are you sure you dont want to [parse it instead?](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags) – Alex Wayne Dec 10 '12 at 08:00
  • @AlexWayne: how can this be parsed? – AabinGunz Dec 10 '12 at 09:07
  • 1
    If the input is HTML, you can use jQuery to parse the HTML and search through the DOM as per normal. Regex is a sub par solution in this case. – nhahtdh Dec 10 '12 at 10:15

1 Answers1

2

Javascript doesn't support positive lookbehinds in its regexes. You can use

str.match(/Converted configuration" alt=([\w]+)/)[1]
int3
  • 12,861
  • 8
  • 51
  • 80