Selecting Text Between Characters in Taskcentre – Using VB Script
In Taskcentre, the text parser tool can be used to extract text between set characters.
A good example is if you have the following input data:
<Result>This is a test</Result>
And wish to extract the following text:
This is a test
This is a good tool, however doesn’t handle errors very well. For example, if the text is not found, it will throw an error message (unless you tell it to ignore errors), which may impact other steps. Additionally the extracted string may be needed in the middle of a Web Service call.
A solution is to use a VBScript function which will handle these errors gracefully. In the example, the function will return a space character if either of the characters are not found. but this can be changed to anything, e.g. “Error”, “String not Found” etc within the function
In the example, the variable Result1 will be set to “This is a test”, whereas Result2 is not found, so is set to a space character.
Full download of the example is available below:
Select String Between Characters Example Script and Task