What are you using to get this string?
This looks like a json string, so you can probably use json_decode() to transform it to an object and then reference the txn_id directly.
If you are using webassist extensions for the transaction, then the TransactionID variable may already be available in the bindings.