Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我还在学习 PHP 正则表达式。我需要从下面提供的字符串中立即返回匹配项的帮助。我需要一个日期(括号之间)和状态(已注册/可访问):
[Feb 28 13:22:37] VERBOSE[1111] chan_sip.c: -- Registered SIP \'1001\' at 127.0.0.1:8080 [Feb 28 13:22:37] NOTICE[1111] chan_sip.c: Peer '1001' is now Reachable. (471ms / 2000ms)
你可以使用这个:
/^\[([^\]]+)\].*(Registered|Reachable)/
第 1 组和第 3 组有您的日期和状态。