0

There have a lot of similar questions on SO. But here is another mental exercise I could not figure out.

Here is the search text:

<span ng-show="vm.formName.fieldName.$error.required">*</span>

Need to replace with just

*

or

<span>*</span>

Obviously we want to replace ng-show="vm.formName.fieldName.$error.required" with an empty string. I thought some * should be used as wildcard for the ng-show attribute. But how?

Is it possible to use wildcard * to take the place of a string that include quotation marks? And how can we avoid the * character in the text from being replaced?

Blaise
  • 21,314
  • 28
  • 108
  • 169
  • [Do not use regex to match HTML. Do not use regex to match HTML. Do not use regex to match HTML.](http://stackoverflow.com/a/1732454/237955) – amphetamachine Jan 20 '15 at 14:53

1 Answers1

3

replace(/ng-show="([\s\S]*)"/,'') should do the trick.

Demo: https://regex101.com/r/jH5fE4/1

Anurag Peshne
  • 1,547
  • 12
  • 29