我有一個配置文件如下:比賽開始或沒有正則表達式
property = 10
#property = 10
#this is a test for #property
#this is a test for property
我試圖拿出一個正則表達式匹配只有第一兩種情況:
property = 10 //this one
#property = 10 //and this one
#this is a test for #property
#this is a test for property
到目前爲止,我所做的就是:
#property.*|^property.*
這是結果:
我試過其他的變種,但結果作最壞的改變:
^#property.*|^property.*
[^\s]#property.*|^property.*
下面是我使用的在線正則表達式的鏈接:
https://regex101.com/r/K2tm75/2
我將在grep命令中使用此正則表達式作爲bash腳本的一部分。
有詢問是否標記正則表達式,如果您標記的語言也將是更好的建議。 –