[英]regular expression for log
我有一個這樣的日志文件:
some strings...
<FX>
another strings...
<FX s='asdf' asd="ascvas">
<TEG1>
<TEG2>
</TEG2>
</TEG1>
</FX>
some strings...
</FX>
some strings...
<FX>
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<FX>
<CLR>
</CLR>
</FX>
end of file
</FX>
我需要在vbscript正則表達式上進行解析以獲取以下結果:
<FX s='asdf' asd="ascvas">
<TEG1>
<TEG2>
</TEG2>
</TEG1>
</FX>
和
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<FX>
<CLR>
</CLR>
</FX>
我已經寫了這個表達式:
(<\?xml[^>]*>[\s\S]*)*<\s*FX[^>]*>((?!<\s*FX[^>]*>)[\s\S])*<\s*/\s*FX\s*>
但這不適用於標記/ FX。 您可以在這里查看rezult: http ://regexr.com?341ps
提前致謝。
這樣更改:
^\<\?xml[^>]*>[\s\S]*<\s*FX[^>]*>((?!<\s*FX[^>]*>)[\s\S])*<\s*/\s*FX\s*>
/(<[^\s]+\s+\w=[^>]+>[^/]+\/[^/]+/[^/]+/[^>]+>)|(<\?xml[^/]+/[^/]+/[^>]+>)/m
# http://regexr.com?386si
/(<[^\s]+\s+\w=[^>]+>[^\/]+\/[^\/]+\/[^\/]+\/[^>]+>)|(<\?xml[^\/]+\/[^\/]+\/[^>]+>)/m
# (escaped forward slash)
# http://rubular.com/r/SwI2vz6ctk
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.