2

I'm using JSHint as Javascript Linter and when executing it I get a "Invalid Regular expression error", the part of the code where I get the error is this:

var regexArray = [
    new RegExp(/<(?<tag>iframe)[^>]*src=(\"|\')(?<src>[^\'\" ]*)\2[^>]*>[\s\S]*?<\/\1>/),
    new RegExp(/<(?<tag>(?:div|span))(?=[^>]*(?:class)=(\"|\')[^\'\"]*embed[^\'\"]*\2)(?=[^>]*(?:data-)?(?:src|source|url)=(\"|\')(?<src>[^\'\" ]*)\3)[^>]*>[\s\S]*?<\/\1>/),
    new RegExp(/<(?<tag>div)[^>]*id=\"fb-root\"(?<src>[^\'\" ]*)\2[^>]*>[\s\S]*?<\/\1>/),
    new RegExp(/<(?<tag>div)[^>]*class=\"fb-post\"(?<class>[^\'\" ]*)\2[^>]*>[\s\S]*?<\/\1><\/\1>/),
    new RegExp(/<(?<tag>script)>[\s\S]*?<\/\1>/),
    new RegExp(/<(?<tag>script)[^>]*src=(\"|\')(?<src>[^\'\" ]*)\2[^>]*>[\s\S]*?<\/\1>/),
    new RegExp(/<(?<tag>div)[^>]*class=(\"|\')(?<class>[pb_feed]*)\2[^>]*>[\s\S]*?<\/\1>/)
]

It points the error after the character > in the tag capture group. I already tested these regex in regex testers like regex 101 and they work as expected. I'm not sure what I might be missing. Thanks in advance for your help.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

0 Answers0