aqString.StrMatches using Regular expressions not working
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
aqString.StrMatches using Regular expressions not working
The following code is using regular expressions in a aqString.StrMatches statement and returns false when it should return true unless I'm coding it wrong. Please help.
aqString.StrMatches("Job ID [0-9] completed successfully", "Job ID 1234 completed successfully")
Thanks.
Solved! Go to Solution.
- Labels:
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Try this:
aqString.StrMatches("Job ID [0-9]+ completed successfully", "Job ID 1234 completed successfully")
('+' added after [0-9])
Does it help?
P.S. https://regex101.com/ may be used to check if regex works as expected.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes it does. Thank you!
I'm curious as to why the plus sign works even though it's imbedded within the quoted string. Is this just how this function accepts string concatenation?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Plus sign here is a part of regex syntax. It means 'any digit from [0-9] range repeated one or more time'.
Without it your regex looked for any single digit from [0-9] range and did not match because the source string contained more than one digit in a row.
P.S. Visit regex101.com and enter your and my regex-es - the pane on the right will provide you with good description of what those regex-es are looking for.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Awesome thanks!
