Home Download Buy Blog Forum Support

regex behaviour

regex behaviour

Postby pierre on Sat Jan 05, 2013 3:48 pm

This code (inside a plugin, but also in the console)

import re
print(re.match("([a-z])\1\1",'aaa'))

produces "None". Why?
Thanks
Piero
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm

Re: regex behaviour

Postby quarnster on Sat Jan 05, 2013 4:16 pm

Because you need to either use raw string notation or escape your back slashes.
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: regex behaviour

Postby pierre on Sat Jan 05, 2013 4:55 pm

Indeed. Thank you!
Piero
pierre
 
Posts: 28
Joined: Sat Mar 19, 2011 8:47 pm


Return to Technical Support

Who is online

Users browsing this forum: TurnitinBot [Bot] and 16 guests