-2

I'm using regex js\w*=\"[^\"]+\" to match and replace tags in HTML that begin with js like jsname="name" jscontroller="somecontroller" etc.

Problem is, if there are spaces before and after the = sign it matches nothing. How can this be solved?

This matches fine jsname="name" jscontroller="somecontroller"

This does not match but should: jsname = "name" jscontroller = "somecontroller"

Can you help?

Norman
  • 6,159
  • 23
  • 88
  • 141
  • 1
    Add `\h*` before and after the equal sign to match for any number of horizontal spaces. – Jeto Aug 31 '20 at 11:51

1 Answers1

0

Use js\w*\s*=\s*\"[^\"]+\"

MLFR2kx
  • 977
  • 7
  • 16