[英]Regex to FindAll chains of strings until a dot with python
I need the regex expression gives to me the word before the : and all until a . 我需要regex表达式让我知道:之前的单词,直到a为止。 The right output will be
正确的输出将是
['Socios: Norberto Alejandro PERONACE, 16/8/1973', 'Joaquin: jaja']
Here is my code: 这是我的代码:
text = "Esc. 7, Fº 10, 14/1/2019, Esc. M. Paula Corallo, Reg. 1525, Socios: Norberto Alejandro PERONACE, 16/8/1973. Joaquin: jaja."
if re.findall(r":", text):
print(re.findall(r"\w+: \w+.\Z", text))
else:
print("Match not found")
You may use 您可以使用
re.findall(r'\S+:[^.]+', text)
See the regex demo 见正则表达式演示
Details 细节
\\S+
- 1+ non-whitespace chars \\S+
-1+个非空白字符 :
- a colon :
-冒号 [^.]+
- 1+ non-dot chars. [^.]+
-1+个非点字符。 See also the Python demo . 另请参阅Python演示 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.