句子中的正则表达式

时间:2018-08-08 06:30:41

标签: python regex

我正在尝试使用this帖子中的日期正则表达式:

 RESTART: C:/Users/snag/AppData/Local/Programs/Python/Python36/Lib/site-packages/tensorflow/contrib/learn/python/learn/datasets/test_alert.py 
[['-LJN3hmc5131KtZB5pkx'], ['-LJN3oaTNwSfSDCHQYsF']]
Traceback (most recent call last):
  File "C:/Users/snag/AppData/Local/Programs/Python/Python36/Lib/site-packages/tensorflow/contrib/learn/python/learn/datasets/test_alert.py", line 26, in <module>
    result = push_service.notify_multiple_devices(registration_ids="-LJN3oaTNwSfSDCHQYsF", message_title=message_title, message_body=message_body)
  File "C:\Users\snag\AppData\Local\Programs\Python\Python36\lib\site-packages\pyfcm\fcm.py", line 261, in notify_multiple_devices
    return self.parse_responses()
  File "C:\Users\snag\AppData\Local\Programs\Python\Python36\lib\site-packages\pyfcm\baseapi.py", line 333, in parse_responses
    raise AuthenticationError("There was an error authenticating the sender account")
pyfcm.errors.AuthenticationError: There was an error authenticating the sender account

但是,我想找到所有也用空格括起来的匹配项。 例如,这句话:

^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$

我想回来:

I went to Disney World on 11/11/1989 and once more on 12/12/2009

我该如何完成?如果有问题,我正在使用Python3正则表达式模块。

1 个答案:

答案 0 :(得分:1)

如果您想调整链接的正则表达式以这样的字符串工作,请将三个set t=20; select * from myTable where age > '${hiveconf:t}'; ^更改为单词边界($):

\b

https://regex101.com/r/WX5Itv/1