I know that there are a lot of answers to vim/regex, but I can't seem to find one that fits the bill for me. So, I'm trying to remove some attributes from HTML using the following:%s/( id=\| onfocus=\| onBlur=\| style=\| title=) [a-zA-Z0-9:;&$_\.\s\(\)\-\,]*//gcI'd like to be able to replace any of the specified attributes and everything up to and included the second =.When I run this, I get pattern not found. However, if I take the parens off of id=\| onfocus=\| onBlur=\| style=\| title= I get a match for id= and I get a match for everything on title=hi How can I include all of the attributes in one regex?Edit: A result of running%s/ id=\| onfocus=\| onBlur=\| style=\| title= [a-zA-Z0-9:;&$_\.\s\(\)\-\,]*//gcwill change<input type=submit id=submit title=submit value=submit />To<input type=submit submit value=submit />You can see it picks up the id= but not the text and double quote after the attribute up to the next space. However, it is pattern matching the correct thing for the title attribute. In this example title=submit has been fully removed.
Creating a regex to match html attributes
regular expression;replace
I found a way to do it: %s/\(id\|class\)=\([^]*\)/\2/gcYou catch id and class in the first group to add the big fat or \| operator.You match =You catch the text you want to keep in the second capture group \([^]*\) (assuming here you want anything up to a ).You match the closing And you leave only the second group.You can then use \2 as you want.