-2

I have this example :

<button type="sasasasasa" abcd="dsqdsq" efgh="sasasa">

I only want to match "button" "type" "abcd" and "efgh".

I already tried : [a-zA-Z:_][a-zA-Z:_.*]* but it matches also what's inside the quotes ""

I thought about taking either "=" or "<" or " " at the beginning to only match but I don't want to have such caracters in my results.

Zeyukan Ich'
  • 651
  • 7
  • 21

2 Answers2

1

You can try this

(?<=<|\s)[a-zA-Z:_][a-zA-Z:_.*][^=|\s]+

This will look after "<" or " " and before "=" or " " but will not include any of the characters.

Check this regex online tester.

Hope this helps

Csa77
  • 649
  • 13
  • 19
Enas Osama
  • 211
  • 1
  • 7
1

Use this:

(?<= |<)[a-zA-Z]*(?==| )

How it works:

  • [a-zA-Z]*: search for any sequence of letters which ...
  • (?<= |<): is preceded by either a < (as in the case of button) or by a space and ...
  • (?==| ): is followed by either a = sign or a space (as in the case of button)

See it on Regex101

Neb
  • 2,270
  • 1
  • 12
  • 22