繁体   English   中英

正则表达式找到匹配模式

[英]Regex to find matching pattern

我需要解析这种文本:

Some text and some 9539 934580 numbers Total number = 45 and then some more text

我需要提取这个:

输出:

Total number = 45

有匹配的空间......

(数字与线路不同)

我怎样才能在正则表达式中获得这种模式?

提前致谢

正则表达式是:

Total number = \d+

要么

Total number = [0-9]+

您可以使用grep

grep -E -o 'Total number = [0-9]+' inputfile > outputfile

-o选项告诉它只打印匹配行的部分。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM