[英]Regex match the last group with @ character on the first character match
How can i match this string permission grant inspire @you @me @john
like this 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
This is my try in regex ^permission\s(grant|deny)\s(.*)\s(.*)
这是我在正则表达式中的尝试
^permission\s(grant|deny)\s(.*)\s(.*)
Note: I'm using javascript, does this need lookbehinds or something else that can look around注意:我正在使用 javascript,这是否需要后视或其他可以环顾四周的东西
Converting my comment to answer so that solution is easy to find for future visitors.将我的评论转换为答案,以便将来的访问者轻松找到该解决方案。
You may consider this regex:你可以考虑这个正则表达式:
^permission\s(grant|deny)\s([^@]+)\s(.*)
Last group has this pattern ([^@]+)
that matches 1+ of any character that is not a @
so that our match stops at the first @
later.最后一组具有这种模式
([^@]+)
匹配任何不是@
的字符的 1+,因此我们的匹配在稍后的第一个@
处停止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.