not sure if someone answered this already, but here you go:
>>> re.findall(r'(?:ch\d{2})|(?:seq\d{2})|(?:s\d{4})', r'P:\<various
directories>\scene\ch01\seq001\s0090\anim\.......')
['ch01', 'seq00', 's0090']
{2} means repeat the pattern 2 times
?: means do not capture inside these parentheses
On Fri, Nov 8, 2013 at 5:35 AM, <[email protected]> wrote:
> asd
> On Tuesday, October 1, 2013 3:36:55 PM UTC+5:30, Panupat Chongstitwattana
> wrote:
> > Hi.
> >
> > I have this string
> >
> > path = r'P:\<various directories>\scene\ch01\seq001\s0090\anim\.......'
> >
> > I want to split out the ch01, seq001 and s0090 into 3 variables (or a
> list). Is there a way to do this with regex in a single line? Maybe with
> re.split(...)
> >
> > Currently I do it in 3 different steps
> >
> > find = re.findall(r'ch\d\d', path)
> > if find: ch = find[0]
> >
> > find = re.findall(r'seq\d\d', path)
> > if find: seq = find[0]
> >
> > etc.
> >
> > Thanks
>
> --
> 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/934d6964-4bbb-42e2-a489-76e424a7e862%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
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/CAGq9Q7F_Fd6qOHUiNRgGt05DTOrMQSgWG9uVq6F2UKzFab%3Dn7g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.