1

I am trying to parse a string to return the text between two sets. For example, my string is: "faultstring>Item not valid: The specified Standard SIP1 Profile was not found faultstring>"

I want to write a function that will return the string: Item not valid: The specified Standard SIP1 Profile was not found

I am new to tcl and your help is very much appreciated.

Please let me know.

Thanks.

1 Answer 1

1

Assuming there is no faultstring> inside the interesting string, and there might be some uninteresting garbage before and after specified fragment:

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"
}

The answer may vary for other assumptions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.