strMatchesby Group Public on Wednesday February 03 2010 @ 10:46:39 (1/1 Points) |
|
| API ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
strMatches is a Condition→ which checks that a string matches the provided regular expression.
if strMatches %SomeString% Regex # Match found end
Groups
If you wish to extract groups/values from a regex you can use the return value. While the primary return value is the condition result, suitable for an if→ statement, the extended results contain the typical regex matching groups.
Each group is stored as %Return:Groups:#% where the # is the matched group, 0 being the entire string.
set %DateLike% 02.12.2004 if strMatches %DateLike% ^([0-9]+)\.([0-9]+).*$ Notice %Return:Group:0% Notice %Return:Group:1% Notice %Return:Group:2% end
Notice that we start the regular expression with ^ meaning to match the beginning of the string. Since we are doing a full match anyways this isn't strictly necessary. However, since a starting open parenthesis indicates a function call in TestPlan, it is a good way to avoid that here.
TestPlan strMatches
