Thursday 27 October 2016

regex - How can I write a regular expression to find/replace HTML classes?

I'm trying to write a regular expression that will match each individual class on HTML elements in an HTML file and allow me to append a string onto the end of each one. I'm using Atom, which is a basic text editor that lets you search with regular expressions.



My end goal is that I want to append a string onto each of the HTML classes on the page. I'm not sure what exactly should be matched by the regex to make the replacement easier - maybe match the character after each class and replace it with the new text plus the old character somehow? Is this even possible?



Examples:

















I know I need to use look-aheads and possibly look-behinds somehow, and now I've gone through a couple tutorials on how to use them, but am still struggling to write a regular expression to solve this problem.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...