0
我想寫一個正則表達式,將捕獲的{alphabetical}
所有出現在字符串中(讓它成爲無,一個或多個),比如:正則表達式捕獲多個字符串佔位符
This is a {variable}
- >[variable]
This is a {variable} and this is {another} one
- >[variable, another]
This is a {variable} and this is {another} {one}
- >[variable, another, one]
我已經設法做/(\{[a-z]+})/
(測試在這裏:https://regex101.com/),但它只是捕獲第一次發生。請幫助我捕捉所有發生的事件,並將其捕獲到組中。
使用'g'標誌:https://regex101.com/r/cE3aQ1/1 –
就解決了! :) – ducin