Reputation: 413
I am new to python and i am trying to lean how regexs work. I would like to capture everything after the GT in this string:
string = re.search(r"(GT\s*)(.)\n", notes)
thanks for the help!
Edit: I would like the output to look like this:
\s*)(.)\n", notes)
Upvotes: 5
Views: 6320
Reputation: 92894
Use the following:
s = 'string = re.search(r"(GT\s*)(.)\n", notes)'
m = re.search(r'GT(.*)', s, re.DOTALL)
print(m.group(1))
The output (contains line-break according to \n
presence):
\s*)(.)
", notes)
Upvotes: 3
Reputation: 3523
in below example every thing catch after @
>>>import re
>>>re.findall(r'@(\w+)', '@hi there @kallz @!')
>>>['hi', 'kallz']
Upvotes: 0