Reputation: 63
I'm using my custom button component like this -> <h-button text primary outline>
. I want to write a regex that would let me select every button that has one or many props. I can easily select everything in the button tag using -> <h-button(.*?)>
regex, but I don't know how to select only a specific word or two.
Let's say I have 3 buttons
<h-button text primary outline>
<h-button primary text outline>
<h-button text success outline>
And I want to find every button that has text
and primary
in it.
Regex should find these two buttons
<h-button text primary outline>
<h-button primary text outline>
Upvotes: 1
Views: 46
Reputation: 396
Try this:
/<h-button .*?(text .*primary|primary .*text).*?>/
https://regex101.com/r/3POnQX/1
Upvotes: 3