gpt4 book ai didi

php - 解析 Skype 日志

转载 作者:可可西里 更新时间:2023-10-31 23:42:36 24 4
gpt4 key购买 nike

我需要解析 Skype 日志,获取所有通话时长并将它们相加,找出整个聊天记录的通话总时长。

示例:

[3/12/2012 11:36:44 AM] * 通话结束,持续时间 21:33 *

我想我需要使用带有正确正则表达式的 preg_match。如果可以同时将实际时间戳存储在数组中,那就更好了。

我认为我真正难过的是仅获取通话时长所需的实际正则表达式规则。

最佳答案

试试这个

(?i)\[(?P<time_stamp>[^[]+)\]\s*[*]\s*[a-z ,]+(?P<duration>(?:\d{2}:?){2,3})\s*[*]

解释

"
(?i) # Match the remainder of the regex with the options: case insensitive (i)
\[ # Match the character “[” literally
(?P<time_stamp> # Match the regular expression below and capture its match into backreference with name “time_stamp”
[^[] # Match any character that is NOT a “[”
+ # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
)
\] # Match the character “]” literally
\s # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
* # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
[*] # Match the character “*”
\s # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
* # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
[a-z ,] # Match a single character present in the list below
# A character in the range between “a” and “z”
# One of the characters “ ,”
+ # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
(?P<duration> # Match the regular expression below and capture its match into backreference with name “duration”
(?: # Match the regular expression below
\d # Match a single digit 0..9
{2} # Exactly 2 times
: # Match the character “:” literally
? # Between zero and one times, as many times as possible, giving back as needed (greedy)
){2,3} # Between 2 and 3 times, as many times as possible, giving back as needed (greedy)
)
\s # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
* # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
[*] # Match the character “*”
"

关于php - 解析 Skype 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11752118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com