Hi Jeremy,

You can put a character in front of a pattern.
>>> re.search(r'v[0-9]+', 'hello_v001')

You can also use \d in-place of [0-9]
>>> re.search(r'v\d+', 'hello_v001')

More here: https://docs.python.org/2/library/re.html


On 4 May 2014 11:47, Jeremy YeoKhoo <[email protected]> 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/2269441f-f499-4a9a-9e08-8226214db73a%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/2269441f-f499-4a9a-9e08-8226214db73a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
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/CAFRtmODDx0Broe-ed7EFpM_FtTaj3UqOkwiSUYiuoyUrZHRFmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to