Forum Discussion
This regex will match your string:
(\d{2}\/\d{2}\/\d{4}) (\d{2}:\d{2}:\d{2}) - (Attempting to connect to DMM\.)
Please remember that / delimiter (as well as another delimiters) always should be escaped by backslash \
Also it is better to escape the dot character: \. Otherwise it will match any character.
And if you group different logical members of your string inside parentheses, it makes your regex more readable.
Great online tool to check your regex: https://regex101.com/
baxatob I used the online tool you recommended and the expression was validated successfully. The problem though is when I plug it into TestComplete for some reason does not like it. I tried to escape the ':' and ''' (single quote) as well for the string under test but no success.
Using the online tool...
This expression:
(\d{2}\/\d{2}\/\d{4})\s(\d{2}\:\d{2}\:\d{2})\s-\s(Attempting to connect to DMM\.)
(\d{2}\/\d{2}\/\d{4})\s(\d{2}\:\d{2}\:\d{2})\s-\s(Attempting to connect to a DMM on port \'COM1\')
(\d{2}\/\d{2}\/\d{4})\s(\d{2}\:\d{2}\:\d{2})\s-\s(Unable to connect to DMM\.)
Matches the following:
09/09/2016 11:25:31 - Attempting to connect to DMM.
09/09/2016 11:25:31 - Attempting to connect to a DMM on port 'COM1'
09/09/2016 11:25:32 - Unable to connect to DMM.
Not sure what else to do.
- baxatob8 years agoCommunity Hero
mcastellanos, can you show how did you use the regular expression within TestComplete framework?
- mcastellanos8 years agoOccasional Contributor
The below is when defining/updating the checkpoint
- baxatob8 years agoCommunity Hero
Hm... Only thing I can advise is to check carefully spaces between records of your log, and how it matches your pattern.
Use \s token everywhere instead of literal spaces.