我需要解析这种文字:
Some text and some 9539 934580 numbers Total number = 45 and then some more text
我需要提取这个:
输出:
Total number = 45
匹配空格......
(数字与线路不同)
如何在正则表达式中获得此模式?
提前致谢
答案 0 :(得分:2)
正则表达式为:
Total number = \d+
或
Total number = [0-9]+
您可以将其与grep
:
grep -E -o 'Total number = [0-9]+' inputfile > outputfile
-o
选项告诉它只打印匹配行的部分。