[英]Regex to find matching pattern
I need to parse this kind of text: 我需要解析这种文本:
Some text and some 9539 934580 numbers Total number = 45 and then some more text
I need to extract this: 我需要提取这个:
Output: 输出:
Total number = 45
with matching spaces... 有匹配的空间......
(NUMBER IS DIFFERENT FROM LINE TO LINE) (数字与线路不同)
How can i get this pattern in a regex? 我怎样才能在正则表达式中获得这种模式?
Thanks in advance 提前致谢
The regular expression is: 正则表达式是:
Total number = \d+
or 要么
Total number = [0-9]+
You can use this with grep
: 您可以使用
grep
:
grep -E -o 'Total number = [0-9]+' inputfile > outputfile
the -o
option tells it to print just the part of the line that matches. -o
选项告诉它只打印匹配行的部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.