2016-11-28 212 views
1

文件的正則表達式結束:猛砸串

xss.filter.rule.lonely_script_tags2=(?ims)<script(.*?)> 
xss.filter.rule.onload=(?ims)onload(.*?)\= 
xss.filter.rule.script_fragments=(?i)<script>(.*?)</script> 
xss.filter.rule.src=(?ims)[\\s\r\n]+src[\\s\r\n]*\=[\\s\r\n]*'(.*?)' 
xss.filter.rule.vbscript=(?i)vbscript\: 
tomcat.javaoptions=-Dasdkalslds \ 
    -agentpath:/opt/hybris/bin/platform/resources/dynatrace/agent/lib64/libdtagent.so=name=hybris-app-1,server=local.com:9998 

我用正則表達式來查找文件包含像字符串:

tomcat.javaoptions= *****Any content and Any times/lines***** 
-agentpath:/opt/hybris/bin/platform/resources/dynatrace/agent/lib64/libdtagent.so=name=hybris-app-1,server=local.com:9998 

CHECK_EXPRESSION="tomcat.javaoptions=(.*\n)*.*agentpath:/opt/hybris/bin/platform/resources/dynatrace/agent/lib64/libdtagent.so=name=hybris.*" 

grep -qP "$CHECK_EXPRESSION" /opt/hybris/config/local.properties 

,但它並不適用於

tomcat.javaoptions=-Dasdkalslds \ 
    -agentpath:/opt/hybris/bin/platform/resources/dynatrace/agent/lib64/libdtagent.so=name=hybris-app-1,server=local.com:9998 

但是工作適用於

tomcat.javaoptions=-Dasdkalslds -agentpath:/opt/hybris/bin/platform/resources/dynatrace/agent/lib64/libdtagent.so=name=hybris-app-1,server=local.com:9998 

我想補充一點,在線正則表達式檢查器顯示我的正則表達式正常。但它不適用於grep。可能問題在於grep。

+0

你必須在你的正則表達式「的hybris應用程序內」額外「應用」,應該是「採用hybris-1」或「雜交體\ d」,而不是 – MYGz

+0

我糾正,但仍沒有運氣 – Tobymaro

+0

你能包括你想在你的問題中匹配更多的行? – MYGz

回答

0

解決!我添加了「z」鍵。它解決問題與新線從人的grep

-z

​​

,--null
輸出一個零字節(ASCII碼NULL字符),而不是通常遵循一個文件名字符。例如,grep -lZ在每個文件名後面輸出 零字節,而不是通常的換行符。此選項使輸出清晰可辨,即使文件名 包含不正常字符(如換行符)。這個選項可以與find -print0,perl-0,sort -z和xargs -0到 等命令一起使用來處理任意文件名,甚至包含那些包含換行符的文件名。