Regular expressions are an incredibly powerful tool, and an understanding of them is a requirement for any aspiring TD.
That said, 2 things they lack are readability and composability. If you are designing a parsing system for naming conventions from scratch I recommend having a look at pyparsing: https://pypi.python.org/pypi/pyparsing/2.0.2 Its object-oriented approach means that you can build up common path patterns that can be reused to form complex but readable compositions. This will make it easier to adapt as your your naming convention grows in complexity over time, and you want to add new directories and name tokens to tell the difference between an export, a stereo render, a working scene file, etc. Chad. — Sent from Mailbox On Mon, May 5, 2014 at 4:47 PM, Jeremy YeoKhoo <[email protected]> wrote: > Hey Eduardo! > That's definitely very useful. Regex is obviously used for some serious > syntax-organising by software developers and those tidbits of information > would invariably be useful for what we do in in CG. I see potential in > using it in this context whereby, say for an example. > <sequence>_<shot>_<version>_<minorversion>.<fileExtension> > Great to know that there is a built-in function as groups() and groupdict() > now > On Sunday, 4 May 2014 20:47:26 UTC+10, Jeremy YeoKhoo wrote: >> >> Hey guys, >> >> This should be fairly easy for you guys who know regex. If I have a string >> that I want to enable versioning, so say for an example I want to recognize >> a string if it contains ['v001', 'v002', etc...] >> I have something like this... >> >> remp= re.search('[0-9]+', 'hello_v001') >> print temp.group() >> >> but I dont want it to return when: >> remp= re.search('[0-9]+', 'hello_001') >> print temp.group() >> >> Thanks >> -Jeremy >> >> > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/2ffb5a33-efa0-4365-b2a0-f8003019255a%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1399342454233.55fc54c5%40Nodemailer. For more options, visit https://groups.google.com/d/optout.
