Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 从组末尾排除字符的正则表达式_Regex_Regex Group - Fatal编程技术网

Regex 从组末尾排除字符的正则表达式

Regex 从组末尾排除字符的正则表达式,regex,regex-group,Regex,Regex Group,我正在尝试分析系统日志行: pam_vas: Authentication <succeeded> for <active directory> user: <bobtheperson> account: <bobtheperson@com.com> reason: <N/A> Access cont(upn): <bob> 实际结果(注意冒号) 代码的链接: 很多尝试和错误让我走到了这一步——我就是不知道如何去掉最后一段

我正在尝试分析系统日志行:

pam_vas: Authentication <succeeded> for <active directory> user: <bobtheperson> account: <bobtheperson@com.com> reason: <N/A> Access cont(upn): <bob>
实际结果(注意冒号)

代码的链接:
很多尝试和错误让我走到了这一步——我就是不知道如何去掉最后一段标点符号

这个正则表达式似乎适合您:

[\>\:]*\s+(.*?)\:?\s\<(.+?)\> 
[\>\:]*\s+(.*?\:?\s\
正如你在这里看到的:

ior


太棒了!我差点就吃到了,好像。谢谢你的快速回复。
Authentication = succeeded
for = active directory
user = bobtheperson
account = bobtheperson@com.com
reason = N/A
Access cont(upn) = bob
Authentication = succeeded
for = active directory
user: = bobtheperson
account: = bobtheperson@com.com
reason: = N/A
Access cont(upn): = bob
[\>\:]*\s+(.*?)\:?\s\<(.+?)\>