1
我試圖獲取兩個特定匹配項之間的字符串,例如兩個hashtags。正則表達式返回兩個匹配項之間的字符串
我想什麼來實現:
輸入:
some text in front ##hi there## some text behind
輸出:
hi there
隨着/%%(.*)%%/
,則返回##hi there##
。
在此先感謝
我試圖獲取兩個特定匹配項之間的字符串,例如兩個hashtags。正則表達式返回兩個匹配項之間的字符串
我想什麼來實現:
輸入:
some text in front ##hi there## some text behind
輸出:
hi there
隨着/%%(.*)%%/
,則返回##hi there##
。
在此先感謝
如果我想要多個匹配,比如說字符串是'there %% are %% two %% matches %% now' – nickosv
,什麼是語言? –
@WiktorStribiżew對不起,我不知道這是相關的。這是PHP – nickosv
只要訪問'$匹配[1]' –