I want to handle 2 cases:
(string)->string@string otherStuff->string
how can it be done?
I want to handle 2 cases:
(string) -> string
@string otherStuff -> string
how can it be done?
import re
def getstring(string):
testforstring = re.search("\((.*)\)",string)
if testforstring:
return testforstring.group(1)
testforstring = re.search("@(.*?)\s+.*",string)
if testforstring:
return testforstring.group(1)
return None
Allows you to do:
>>> print getstring('(hello)')
hello
>>> print getstring('@hello sdfdsf')
hello