我想寫一個正則表達式來匹配出現在兩個字符之間的所有字符串(很可能是"
- 雙引號)。這是我在嘗試解析csv文件中的一行時經常遇到的場景。正則表達式提取所有在引號
所以我有這樣一個樣本行:
"Smith, John",25,"21/45, North Avenue",IBM
試過以下的正則表達式:
"(.*)"
但有些獲取如下:
我期待輸出如下:
Smith, John
25
21/45, North Avenue
IBM
我寫的正則表達式試圖捕獲在我的示例中的"
之間的內容。但是,以上是我期望的輸出。
雖然有一種含糊不清的情況:我不是在尋找像這樣的匹配:,25,
。這有點讓我懷疑在這裏正則表達式是否可行。
寫這個的正確方法是什麼?
' 「([^」] *) 「'或'」「'可以工作,但它會創建另一個(*?)問題 –
你使用哪種語言的正則表達式? –
@SalmanA你能解釋一下有問題的場景嗎? – deostroll