0
好了,所以我有輸入的正則表達式的一組中捕捉多個數字
textsem:Predicate xmi:id="1695" sofa="1" begin="67" end="71" relations="1869 1879 1889" frameSet="lead.03"
& &
textsem:Predicate xmi:id="1709" sofa="1" begin="135" end="142" relations="1842 1852" frameSet="lead.03"
形式我想提取僅使用正則表達式的關係,並追加值列表。
我使用正則表達式是:
(relations=)(")(\d+\s*)+(")
然而,當我嘗試添加組(3)進入我的列表它只是在捕捉每一行的最後一個值。即在上面的示例輸入中,它僅分別獲得1889年和1852年,我不知道爲什麼。任何幫助表示讚賞。
謝謝!
使用:'relations =「((?:\ d + \ s *)+)」' – anubhava
我發佈的正則表達式捕獲我需要的正則表達式。使用關係=「((?:\ d + \ s *)+)」有什麼好處嗎? – jdv12
你有不必要的組,但你只需要一個組。 – anubhava