Search code examples
htmlsublimetext3sublimetext

How to find multiline attributes using Sublime Text


I been using style='(.*?) (in the find box) to replace the entire style attribute:

Example:

<a style='width: 68px';text-align:center'> < /a>

How can i do to find multiline style?

Example:

<a style='width: 68px';text-align:center;
 padding:0cm 3.5pt 0cm 3.5pt;height:90.0pt'> < /a>

Note: The original code is from office word (table) export (that's why multiline attributes)


Solution

  • Use this regular expression:

    style='((.|\n)*?)'
    

    The only difference is that . was replaced by (.|\n) which matches . or new line characters \n. If you use \r\n as end of line sequence, you need to use that sequence instead of \n.

    Demo on regex101.com.