Hi Eric, These should work:
var classes = 'your .string'.match(/\.[a-zA-Z_-]+/g); var ids = 'your #string'.match(/#[a-zA-Z_-]+/g); var idsAndClasses = '#your .string'.match(/(\.|#)[a-zA-Z_-]+/g); --Karl ____________ Karl Swedberg www.englishrules.com www.learningjquery.com On Mar 20, 2009, at 11:32 AM, Eric Garside wrote:
I need to come up with a regex, or find some way to leverage Sizzle (which I'm not familiar with) to do a pretty simple task. Given strings like: div#some-complex-id.myClass.ui-state-disabled or p.myClass#someId.otherClass or p .myClass .otherClass .ui-state-disabled #myId I'd like, through one or two regex arguments (ideally, one which return me classes, one which will return an ID), arrays containing the classes/id in the string. I hope I'm that was clear. It seems like it'd be simple for someone who knew what they were doing with regex. Sadly, I do not. :\