Reputation: 95
I am trying to write a regular expression that matches a number which is between parentheses.
Sample input lines:
Resolution(03:03): the software is installed
Resolution(10:12): software removed
Resolution(05:01): Software configuration
I want to match:
03:03
10:12
05:01
Numbers have different values. eg,
01:01 - 01:99 01:01 - 99:01 99:01 - 99:99
The message part contains only one text, eg:
Message cancel by the user
How can I search this text using "contains" function?
Upvotes: 1
Views: 191
Reputation: 425268
To match only the numbers, use look behind/ahead assertions:
(?<=\()\d\d:\d\d(?=\))
Look arounds assert without capturing, so the entire match is just the numbers part. The brackets are asserted, but not part of the match.
Upvotes: 1
Reputation: 1174
(\d{2}:\d{2})
- Your regexp\((\d{2}:\d{2})\)
- or this oneResolution\((\d{2}:\d{2})\)
- or maybe with "Resolution" keyword?Website you should read if want use REGEXP like a PRO
Upvotes: 1