简体   繁体   English

Python 正则表达式 - 获取 Substring 以部分单词开头并以某个字符结尾

[英]Python Regex - Get Substring Starting with part of word and ending with certain character

I've searched the forum high and low and just can't seem to piece together the knowledge to build a python regex for this.我搜索了论坛的高低,似乎无法拼凑知识来为此构建 python 正则表达式。 I need to get the date (Tuesday, May 12) out of this string.我需要从这个字符串中获取日期(5 月 12 日,星期二)。 The actual date will vary, but will always include a day of the week (ex: Tuesday).实际日期会有所不同,但始终包括一周中的某一天(例如:星期二)。

["Text content goes here,","week","Yes","Tuesday, May 12",2,"110519",2]

a = ["Text content goes here,","week","Yes","Tuesday, May 12",2,"110519",2] b = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday": "Sunday"] for text in a: for day in b: if type(day) == type(text): if day in text: print(text) a = ["文本内容放在这里,","week","Yes","Tuesday, May 12",2,"110519",2] b = ["Monday", "Tuesday", "Wednesday", " Thursday", "Friday", "Saturday": "Sunday"] 对于 a 中的文本:对于 b 中的天:如果 type(day) == type(text): if day in text: print(text)

Try this.尝试这个。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 正则表达式在Python中某个字符之前抢单词 - Regex to grab word before a certain character in python 正则表达式在以字符结尾的单词开头分割 - regex split at start of word ending in character Python正则表达式在单词的中间找到具有指定字符的单词,而不以字符开头或结尾。 - Python regex find words with specified character in middle of word not beginning or ending with character. 正则表达式提取 HTML 中不同起始和结束字符串之间的子字符串 - Regex to extract substring between different starting and ending strings within HTML Python:在Python中查找并删除以特定子字符串开头和结尾的字符串 - Python: Find and remove a string starting and ending with a specific substring in python Python:获取两个给定子字符串之间的子字符串开始和结束 - Python: getting substring starting and ending between two given substrings 在python中查找并删除以特定子字符串开头和结尾的字符串 - Find and remove a string starting and ending with a specific substring in python 正则表达式不能替换以“。”开头或以“ +”结尾的单词,例如“ .NET”或“ C ++” - regex not replacing word starting with “.” or ending with “+” like “.NET” or “C++” Python正则表达式以字开头分割 - Python regex to split at word starting with python中某个字符类型的最长连续子字符串 - Longest consecutive substring of certain character type in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM