1

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.

Example:

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.

Expected result:

Regex should find these two buttons

<h-button text primary outline>
<h-button primary text outline>
0

1 Answer 1

3

Try this:

/<h-button .*?(text .*primary|primary .*text).*?>/

https://regex101.com/r/3POnQX/1

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.