As I often work in Dreamweaver for basic CSS work ... DW code completion tends to add CSS attribute values directly after the colon without spacing ... {attr:value}. As this has caused some real debugging headaches due to rendering issues with picky browsers, I often find myself having to manually add the space after the colon. [^D.R.Y.]
I'm currently working on building a simple regex snippet that I can run to format the CSS properly ...
What I currently have seems to work but I think it's a bit crude ... I'm basically just trying to see if there are any suggestions ... Here's what I've got ...
(.*?(?={).*?:)([^\s][\w!#$%&'*+/=?^_`{|}~-]*.*?;})
And Replacing the line with ...
\s$2
► Clarification ► Below I've Somewhat Improved the Solution Above ... I Still Think It Needs Refinement Though ...
(?:(?={*))(?:\s*?)([\s\r\n]*?\b[\w!#$%&'*+/=?^_`|~-]*:(?!.*{))(?!\s)(.*?;)
And Replacing With ...
$1 $2
► Perl Version ►
Perl makes very light work of this ...
perl -pi -e 's/^(.*?:)([^\s].*?;).*$/$1 $2/ig'