我有一个脚本,其返回形式为-
的字符串 http-STYPE-CONNECT-new/mydir/20200215_14-30-01/http/PAY_STYPE-CONNECT-new/ "Check for atleast one http 200": Expression '($1=="r" && $13==200)' matched 0 time(s), which is below specified min of 1
http-PARALLEL-new/mydir/20200215_14-30-01/http/PAY_PARALLEL-new/ "Check for atleast one http 200": Expression '($1=="r" && $13==200)' matched 0 time(s), which is below specified min of 1
http-STYPE-new/mydir/20200215_14-30-01/http/PAY_STYPE-new/ "Check for atleast one http 200": Expression '($1=="r" && $13==200)' matched 0 time(s), which is below specified min of 1
http-STYPE-CONNECT-0RTT-new/mydir/20200215_14-30-01/http/PAY_STYPE-CONNECT-0RTT-new/ "Check for atleast one http 200": Expression '($1=="r" && $13==200)' matched 0 time(s), which is below specified min of 1
我想以这样一种方式分割(或应用正则表达式)每个字符串,以使第一个'/'之前的所有 存储在变量test_name
中,而所有之间的所有< / em>路径的第一个'/'和最后一个'/' 存储在变量path
中,并且路径的最后一个'/'之后的所有内容存储在变量failure_reason
中。
示例:
test_name = http-STYPE-CONNECT-new
path = /mydir/20200215_14-30-01/http/PAY_STYPE-CONNECT-new/
failure_reason = "Check for atleast one http 200": Expression '($1=="r" && $13==200)' matched 0 time(s), which is below specified min of 1
还有另外两种可能使解析变得复杂-
\n
。例如:路径的最后一个'/'之后。由于我是新手,所以我只是尝试在python3中使用split('/'), join(), strip()
函数,但无法真正获得想要实现的目标。
任何帮助将不胜感激。谢谢