[Solved] Regular Expression to get text from css
If you have CSS styles isolated in a javascript string, you can get the width value with this regex: var re = /\.body\s*\{[^\}]*?width\s*:\s*(.*);/m; var matches = str.match(re); if (matches) { var width = matches[1]; } Test case here: http://jsfiddle.net/jfriend00/jSDeJ/. The height value can be obtained with this regex: \.body\s*\{[^\}]*?height\s*:\s*(.*);/m; If you just want the text … Read more