-1

I'm trying to find html tags in a text, like this:

'<span style="background-color: #aaaaaa">'

But the color part can change ( like to #bbbbbb )... I think I can use regex for this, right? But I'm not sure how I can just ignore the color part of it...

Can you help me? Is this possible?

Thank you so much ^^

user5646514
  • 69
  • 2
  • 9

1 Answers1

1

try this '<span style="background-color: #aaaaaa">'.match(/#[0-9a-fA-F]+/)

Linh Nguyen
  • 925
  • 1
  • 10
  • 23
  • Don't you think using `match(/#[0-9a-fA-F]+/g)` would be better to capture multiple colour codes thar might be included in the string. Your example will only return the first one. **Example** `'some text #ffff here more text '.match(/#[0-9a-fA-F]+/g)` – NewToJS Dec 06 '19 at 04:55
  • I will try it with the /g! – user5646514 Dec 06 '19 at 05:00
  • 1
    I doubt this can help with the problem or even work at all. To convince me otherwise, please explain how your proposed solution works and how it solves the problem. – Yunnosch Dec 06 '19 at 07:40