1

我正在尝试解析一个字符串以返回两组之间的文本。例如,我的字符串是:“faultstring>Item not valid: The specified Standard SIP1 Profile was not found faultstring>”

我想编写一个返回字符串的函数:Item not valid: The specified Standard SIP1 Profile was not found

我是 tcl 的新手,非常感谢您的帮助。

请告诉我。

谢谢。

4

1 回答 1

1

假设faultstring>有趣的字符串内部没有,并且在指定片段之前和之后可能有一些无趣的垃圾:

set testString "faultstring>Item not valid: The specified Standard SIP1 Profile was not found faultstring>"

if {[regexp {faultstring>(.*)faultstring>} $testString _ extracted]} {
     puts "Got it: $extracted"
}

对于其他假设,答案可能会有所不同。

于 2013-01-25T19:45:57.567 回答