On 06Jan2015 11:43, Norman Khine <nor...@khine.net> wrote:
i have the following code:
[...]
#t(" ") gettext_re = re.compile(r"""[t]\((.*)\)""").findall
My first thought is: "[t]" can just be written "t" [...]
so, gettext_re = re.compile(r"""[t]\((.*)\)""").findall is not correct as it includes results such as input( type="hidden" name="_csrf" value=csrf_token ) what is the correct way to pull all values that are within t(" ") but exclude any tt( ) and input( )
Others have suggested word boundaries and nongreedy matches. You don't need them.
Use this: \([a-zA-Z]\w*\)(\([^)]*\)) which matches any "foo(blah)". Then look at the returned match object and check that .group(1) == "t". Cheers, Cameron Simpson <c...@zip.com.au> I heard a funny one this weekend. I was belaying a friend on a very short problem and when she was pumped out she told me to "Let me down" and my other friend that was standing nearby said. "You were never UP!". - Bryan Laws <bryanl...@aol.com> _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor