我想要一個正則表達式,每次都捕獲+other
以及所有內容,直到下一個逗號。正則表達式捕獲一個模式加上一切後的所有內容,直到達到一個字符
隨着
(word),+(other)(word),(code),(word),(other)(code),(example)
(code),+(other),+(other)(code)(word)(example),(example),+(example)
+(code),(other)(code)(word),(code),(word)
我想回到
+(other)(word)
+(other)
+(other)(code)(word)(example)
我的命令,我會用看起來像egrep -o '\+\(other).*,
。 唯一的問題是,這個正則表達式中的逗號不一定是下一個逗號。眼下命令返回
+(other)(word),(code),(word),(other)(code),
+(other),+(other)(code)(word)(example),(example),
所以,試圖'egrep的-o「\ + \(其他)[^,] *, '還沒? –
而不是預期的輸出?從「+(其他)」到* first *逗號的字符串?爲什麼不能用'+(other)(code)(word)(example)'來匹配?請用推理更新問題。 –
因此,編輯後,看起來像'egrep -o'\ + \(其他)[^,] *'應該足夠了嗎? –