0

I'm working on the following strings:

d.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{}; source

the same with source repositioned (this is a good case to catch source):

d.innerHTML= lala; possibly other stuff; source "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{}; 

I'm trying to capture any case that an innerHTML takes the string "source" in its value. I tried this regex to match anything between the two strings:

innerHTML=(.*?)source

But it fails as it will keep searching for the "source" keyword in the entire page (and will match everything on the way). So I tried setting a limit that represent function end, such as:

innerHTML=(.*?)(source|[})\]\n])

But this also failed, since it still matches anything up until what I've set (remember - I only want to match when source actually exists).

I have no idea how to perform this, without generating false positives whereever "source" is mentioned outside the innerHTML value. Please help?

toti
  • 139
  • 1
  • 2
  • 9
  • Well, on second thought, you probably can just use a negated character class here, `innerHTML="([^})\]\n]*?)source`, if you need to negate just a set of chars, you do not need any complex structures. – Wiktor Stribiżew Apr 09 '19 at 12:50
  • That is perfect mate, worked, thanks. – toti Apr 09 '19 at 13:02

0 Answers0