I have to match, of style contains, for example, color. This is string:
<a href="#" style="margin:50px;color:2;">test</a>
And my regex:
/(color:(.);)/
It works now, what I need to do, so it will also match color: 2;?
Use \s* to match optional space characters:
/(color:\s*(.);)/
(.) will match only a single character color. If you want to match another colors with more characters, use following regular expression:
/(color:\s*([^\s;]+)\s*;)/
(used \S to match non-space character)
color is not at the end.;: /(color:\s*([^\s;]+)\s*;)/
?, which is a feature documented on the first page of any regexp introduction you'll find on the web. That first page will also talk about another operator, the asterisk, which matches zero or more of something, so ` *` is zero or more spaces, which is probably what you're looking for.element.style.fontSize = '';. CSS is a language, and it's never a good idea to try to parse or rewrite anything but the simplest language with regexps. They will break, and be hard to maintain. If you want to experiment with regexps, start with some sample problems which are more suited to regexps.