Python正则表达式在破折号之间查找alpha字符串

2024-04-19 17:19:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一系列的字符串,大致上都是这样的。你知道吗

- Conf. w/attorney, defendant, bondsman. Magistrate ct., PA - Research - 2.7 hrs - 86 miles

我需要写一个正则表达式来匹配

- Conf. w/attorney, defendant, bondsman. Magistrate ct., PA -

字符串的- Research -部分。你知道吗

但不是hrsmiles片段。你知道吗

x = re.findall('-[.^\-0-9]*-', line)

到目前为止我已经试过了,但是没有任何匹配结果。你知道吗

我肯定我只是写错了。你知道吗


Tags: 字符串reconflinectresearchpahrs