[英]Regex match the last group with @ character on the first character match
我怎樣才能匹配這個字符串permission grant inspire @you @me @john
喜歡這個匹配
Group 1: grant or deny
Group 2: anything character
Group 3: should match start with @ every character in match like @you @me you and this is splitted by splace
這是我在正則表達式中的嘗試^permission\s(grant|deny)\s(.*)\s(.*)
這是我的小提琴
注意:我正在使用 javascript,這是否需要后視或其他可以環顧四周的東西
將我的評論轉換為答案,以便將來的訪問者輕松找到該解決方案。
你可以考慮這個正則表達式:
^permission\s(grant|deny)\s([^@]+)\s(.*)
最后一組具有這種模式([^@]+)
匹配任何不是@
的字符的 1+,因此我們的匹配在稍后的第一個@
處停止。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.