[英]Capturing text after a certain character in a string python
I am new to python and i am trying to lean how regexs work. 我是python的新手,我正在努力学习正则表达式的工作原理。 I would like to capture everything after the GT in this string: 我想在这个字符串中捕获GT之后的所有内容:
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)
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): 输出(根据\\n
存在包含换行符):
\s*)(.)
", notes)
in below example every thing catch after @ 在下面的例子中,每件事都赶上@
>>>import re
>>>re.findall(r'@(\w+)', '@hi there @kallz @!')
>>>['hi', 'kallz']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.