我想是的後面是一個關鍵的詞「量」正則表達式查找後面
preg_match_all("/amount.+\b(\d+(\.\d+)?)/im", $input_lines, $output_array);
我輸入的數據是
here is some number 100.25
that does not 200.
but this amount should be captured 300.
and this amount should be captured 400.25 too
and this amount should be captured $5023 too
and this amount should be captured $60.25 too
and this amount should be captured 700.25.
But not this amount 800.25.2
文本中捕捉數量的關鍵詞數量
所以只有數字300,400.25,5023,60.25,700.25應該被捕獲
我想我想通拿出你想要的東西,但你應該真正解釋數字應該與不應該匹配的邏輯。 – Theo