我嘗試了幾個其他鏈接,如Regex Match all characters between two strings和Regex get all content between two characters 但它們似乎不符合此用例。正則表達式匹配2個字符之間的所有字符串
我想得到所有的名字,土豆和番茄。例如,從|
到>
。
text = "with <@U0D08NR3|potato> and <@U1698M96|tomato> please"
text.scan((?<=|).*?(?=>))
似乎沒有工作,要麼..
請指引我的正則表達式的神。
['<@ [A-Z0-9] {8} \ |(。*?)>'](https://regex101.com/r/X8PQ3P/1) – Tushar