Hi there,
I am using regular expressions like this:
matcher = re.compile(r'(. *)\s(.*)', re.UNICODE)
tmp = matcher.search( mystring)
if tmp:
myvariable = tmp.group(1)
The idea is that group(1) is accessed only if
it was found from 'mystring'. Is there a way
to avoid the usage of 'tmp' -variable?
Sure, I could try:
matcher = re.compile(r'(. *)\s(.*)', re.UNICODE)
if matcher.search( mystring):
myvariable = matcher.search( mystring).group (1)
but then I am searching 'mystring' twice.
-pekka-
I am using regular expressions like this:
matcher = re.compile(r'(. *)\s(.*)', re.UNICODE)
tmp = matcher.search( mystring)
if tmp:
myvariable = tmp.group(1)
The idea is that group(1) is accessed only if
it was found from 'mystring'. Is there a way
to avoid the usage of 'tmp' -variable?
Sure, I could try:
matcher = re.compile(r'(. *)\s(.*)', re.UNICODE)
if matcher.search( mystring):
myvariable = matcher.search( mystring).group (1)
but then I am searching 'mystring' twice.
-pekka-
Comment