I’m feeling particularly nit-picky today. I’m working in some HTML docs that have single quotes around all attribute values through the docs, like this:
<div class='classone classtwo'>
I’d love to be able to do a find-and-replace in each doc and replace with double quotes, like this:
<div class="classone classtwo">
Many elements in the document will have multiple attributes:
<div class='classone classtwo' data-scripts='lazyload'>
And some will have the correct double quotes:
<div class='classone classtwo' data-scripts="lazyload">
What’s the best way to replace all single quotes wrapping values with double?
Doing a “replace” operation, I might try something simple like this:
Find What:
=\s*'(.*?)'Replace With:
="$1"Make sure to enable the Regular Expression toggle button (
.*)The nice thing about doing this in SublimeText2 is that it will immediately show you which sections are going to be matched before you perform the replace. So the regex doesn’t have to be fullproof.