[英]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.