Python正则表达式找到一个单词后的第一个单词

时间:2017-11-30 21:45:35

标签: regex python-2.7

我是regex的新手。 所以我很抱歉,如果这是一个愚蠢的问题。 我有一根长串(见下文)

If you require further assistance please contact us by sending email to
export@cisco.com.

Cisco                 7206VXR (NPE400) processor (revision A) with 491520K/32768K bytes of memory.
Processor board ID 4279256517
R7000 CPU at 150MHz, Implementation 39, Rev 2.1, 256KB L2 Cache
6 slot VXR midplane, Version 2.1

我正在尝试提取子字符串“7206VXR”。 从这里查看后,我找到了解决问题的方法 https://regex101.com/ 解决方案1是

re.search(r"Cisco((\s*)(\w*).*)(bytes of memory)
uptime = hostUptimeRegex.group(3)
print "hostUptimeRegex.group(3) is :" + uptime + ":"

enter image description here 我想知道的是,是否有更好的方式

  

在以“Cisco”开头的句子中找到 第一个“word” (即两边用空格包围的一系列字母数字字符)以“内存字节”结尾。

0 个答案:

没有答案