【发布时间】:2021-12-03 18:43:57
【问题描述】:
我有一个字符串long string: its a teamcity buildLog
这是来自 teamcity 的 buildLog。
[11:27:30] : [Step 5/5] 15:27:30 INFO: Average times: total 0.455, latency 0.455, connect 0.004
[11:27:30] : [Step 5/5] 15:27:30 INFO: Percentiles:
[11:27:30] : [Step 5/5] +---------------+---------------+
[11:27:30] : [Step 5/5] | Percentile, % | Resp. Time, s |
[11:27:30] : [Step 5/5] +---------------+---------------+
[11:27:30] : [Step 5/5] | 0.0 | 0.021 |
[11:27:30] : [Step 5/5] | 50.0 | 0.103 |
[11:27:30] : [Step 5/5] | 90.0 | 1.166 |
[11:27:30] : [Step 5/5] | 95.0 | 2.27 |
[11:27:30] : [Step 5/5] | 99.0 | 2.77 |
[11:27:30] : [Step 5/5] | 99.9 | 6.996 |
[11:27:30] : [Step 5/5] | 100.0 | 10.312 |
[11:27:30] : [Step 5/5] +---------------+---------------+
[11:27:30] : [Step 5/5] 15:27:30 INFO: Request label stats:
[11:27:30] : [Step 5/5] +------------------------------------------+--------+---------+--------+-------------+
[11:27:30] : [Step 5/5] | label | status | succ | avg_rt | error |
[11:27:30] : [Step 5/5] +------------------------------------------+--------+---------+--------+-------------+
[11:27:30] : [Step 5/5] | Activity History | OK | 100.00% | 1.608 | |
[11:27:30] : [Step 5/5] | Asset Allocation | OK | 100.00% | 0.100 | |
[11:27:30] : [Step 5/5] | Dashboard Cards and Employee Information | OK | 100.00% | 0.255 | |
[11:27:30] : [Step 5/5] | Fund Details | OK | 100.00% | 0.825 | |
[11:27:30] : [Step 5/5] | Investments | OK | 100.00% | 0.132 | |
[11:27:30] : [Step 5/5] | Minimum Version | OK | 100.00% | 0.032 | |
[11:27:30] : [Step 5/5] | Rate of Return | OK | 100.00% | 0.047 | |
[11:27:30] : [Step 5/5] | Retirement Outlook Card | OK | 100.00% | 1.166 | |
[11:27:30] : [Step 5/5] | Retirement Outlook Full | OK | 100.00% | 1.160 | |
[11:27:30] : [Step 5/5] | Savings Rate | OK | 100.00% | 0.112 | |
[11:27:30] : [Step 5/5] | Secure Auth Login | FAIL | 98.58% | 0.207 | Bad Request |
[11:27:30] : [Step 5/5] | Validate Savings Rate Change | OK | 100.00% | 0.127 | |
[11:27:30] : [Step 5/5] | Vested Balance | OK | 100.00% | 0.157 | |
[11:27:30] : [Step 5/5] +------------------------------------------+--------+---------+--------+-------------+
[11:27:35] : [Step 5/5] 15:27:35 INFO: Ending data feeding...
[11:27:36] : [Step 5/5] 15:27:36 INFO: Online report link: https://a.blazemeter.com/app/#/masters/36669958
从上面的构建日志中,我必须获取 Percentiles Table 、 Request Label Stats 表和 Online Report Link
我尝试了下面的代码,但它没有返回:
$firststring = "Percentiles:"
$secondstring = "Request label stats:"
$pattern = "$firststring(.*?)$secondstring"
$result = [regex]::Match($file,$pattern).Groups[1].Value
$result >> returns none
下面的代码来获取字符串。
$Regex = [Regex]::new("(?<=Percentiles:)(.*)(?=Request label stats:)")
$Match = $Regex.Match($status)
if($Match.Success)
{
$Match.Value
}
这也没有返回。 任何帮助将不胜感激。
【问题讨论】:
-
你真的是想用powershell-3.0标记这个吗?
-
但是..这基本上就是字符串中的全部内容。
标签: string powershell teamcity