C# CSS Classname Regex

<p>As promised, although a little late I have updated the Regex to get CSS classnames via C#. The problem I had was that it would find file extensions in a url specified by the "url(xyz.png)" in an attribute.<p />I added a little n…


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan

<p>As promised, although a little late I have updated the Regex to get CSS classnames via C#. The problem I had was that it would find file extensions in a url specified by the "url(xyz.png)" in an attribute.<p />I added a little negative look behind and now it seems to work prety well:<p />string css = @".someclass{background: white url(someimage.png) repeat-x top left;}.someclass2{background: white url ( someimage.png) repeat-x top left;}";MatchCollection arr = Regex.Matches(css, @"(?<!url\s*(.*)(.[-]?[_a-zA-Z][_a-zA-Z0-9-]*|[^\0-\177]*\[0-9a-f]{1,6}(\r\n[ \n\r\t\f])?|\[^\n\r\f0-9a-f]*)");string class1 = arr[0].Value;string class2 = arr[1].Value;<p /></p>


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan


Print Share Comment Cite Upload Translate Updates
APA

Paul Kinlan | Sciencx (2006-02-24T00:00:00+00:00) C# CSS Classname Regex. Retrieved from https://www.scien.cx/2006/02/24/c-css-classname-regex/

MLA
" » C# CSS Classname Regex." Paul Kinlan | Sciencx - Friday February 24, 2006, https://www.scien.cx/2006/02/24/c-css-classname-regex/
HARVARD
Paul Kinlan | Sciencx Friday February 24, 2006 » C# CSS Classname Regex., viewed ,<https://www.scien.cx/2006/02/24/c-css-classname-regex/>
VANCOUVER
Paul Kinlan | Sciencx - » C# CSS Classname Regex. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2006/02/24/c-css-classname-regex/
CHICAGO
" » C# CSS Classname Regex." Paul Kinlan | Sciencx - Accessed . https://www.scien.cx/2006/02/24/c-css-classname-regex/
IEEE
" » C# CSS Classname Regex." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2006/02/24/c-css-classname-regex/. [Accessed: ]
rf:citation
» C# CSS Classname Regex | Paul Kinlan | Sciencx | https://www.scien.cx/2006/02/24/c-css-classname-regex/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.