the following syntax is part of perl script with Irregular Expression
as we see the target of the following syntax is to get VALID IP address
as 123.33.44.5 or 255.255.0.0 etc
but how to change the following syntax if I want to valid also the IP:
for example:
124.33.*.*
(I want to valid also the * character as valid number 1-255)
example of valid IP’s
*.1.23.4
123.2.*.*
*.*.*.*
*.*.198.20
example of not valid IP’s
123.**.23.3
289.2.2.2
21.*.*.1000
" *.*.*.**"
#
my orig code:
my $octet = qr/[01]?\d\d?|2[0-4]\d|25[0-5]/;
my $ip = qr/ \b
(?!0+\.0+\.0+\.0+\b)
$octet(?:\.$octet){3}
\b
/x;
You have 2 problems:
Need to add “*” to octet definition.
Much worse – “*” matches word boundary (\w). So you should instead use explicit character class for ip-boundary:
[^\d*]OUTPUT: