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.
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.
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?
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.