I am trying to capture IP addresses or version numbers via regex. Here are are my three conditions -
Condition1 :- Match if only single digits in all the four octets.
E.g. - oids.serialNumber = '2.5.4.5';
Condition2 :- Don't match if more than 3 dots.
E.g. - "System.Data.Entity": "4.0.0.1.0";
(4 dots here.)
Condition3 :- IP/Version number may or may not be in the middle of the string.
E.g. - "System.Data.Entity": "4.0.0.1.0";
(middle of the string)
E.g. - 1.0.0.0
- (start of the string)
I have created this regex - ([0-9]\.[0-9]\.[0-9]\.[0-9])
to capture the above but while running the test cases, i am not getting proper results.
Here are my test cases -
1.0.0.0 - Detect
"System.DirectoryServices": "11.0.0.0" - Don't Detect
"System.Web.Services": "244.0.0.0", - Don't Detect
"System.Security": "4.01.0.0", - Don't Detect
"System.DirectoryServices.AccountManagement": "4.011.0.0", - Don't Detect
"System.Data.Entity": "4.0.01.0", - Don't Detect
oids.street = '2.5.244.9'; - Don't Detect
oids.serialNumber = '2.5.4.5'; - Detect
oids.serialNumber = '2.5.4.11'; - Don't Detect
oids.serialNumber = '2.5.4.111'; - Don't Detect