Reputation: 925
I need to write a regular expression to catch the following things in bold
class="something_A211"
style="width:380px;margin-top: 20px;"
I have no idea how to write it, can someone help me?
I need this because, in html file i have to replace (whit notepad++) with empty, so i want to have a clear < tr > or < td > or anything else.
Thank you
Upvotes: 0
Views: 43
Reputation: 1230
For all constructions like something="data"
, you can use this.
[^\s]*?\=\".*?\"
https://regex101.com/r/oQ5dR0/1
The link shows you what everything does.
To explain it briefly, a non space character can come before the "=" any mumber of times, then comes the quotes and info inside of them.
The question mark in .*?
(and character any number of times) is needed so only the minimum amount of characters will be used (instead of looking for the next possible quotes somewhere further along)
Upvotes: 1
Reputation: 30995
You can use a regex like this to capture the content:
((?:class|style)=".*?")
However, if you just want to match and delete that you can get rid of capturing groups:
(?:class|style)=".*?"
Upvotes: 1