amites Posted February 26, 2008 Share Posted February 26, 2008 Hello, I'm rather new to writing Regex and have a simple request, what I have is a collection of scripts that I wrote rather quickly, now the scripts work and place things inside of different div boxes and other class and id definitions, however I Haven't created a css file to format everything and I'd like to create a function to parse a folder searching for all class names matching class="[class name]" and id names matching id="[id name]" then run that group through a foreach loop to write to a css file .[class name] { } #[id name] { } I can handle the opening the directory, and parsing the array once it's been built from preg_match_all though building the regex query itself is giving me some trouble, probably has to do with the 15 hour day I've pulled so far *heh* any help is appreciated Quote Link to comment Share on other sites More sharing options...
effigy Posted February 26, 2008 Share Posted February 26, 2008 Do you have access to Unix and Perl? This would give you a listing to work from: find . -type f -exec perl -n -e 'print "$1|$2\n" if /\b(class|id)="([^"]+)/' {} \; | sort -u If not, you can still borrow the expression. Quote Link to comment Share on other sites More sharing options...
amites Posted February 26, 2008 Author Share Posted February 26, 2008 I was planning on building this into a php function and running it on my computer, if it works probably release it open source, seems like a simple way to save some time when building larger projects, not have to deal with tracking CSS classes and ID's just using good labels I'll see how that works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.