Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1058203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:59:24+00:00 2026-05-16T17:59:24+00:00

the following syntax is part of perl script with Irregular Expression as we see

  • 0

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:59:25+00:00Added an answer on May 16, 2026 at 5:59 pm

    You have 2 problems:

    1. Need to add “*” to octet definition.

    2. Much worse – “*” matches word boundary (\w). So you should instead use explicit character class for ip-boundary: [^\d*]

      my $octet = qr/[01]?\d\d?|2[0-4]\d|25[0-5]|[*]/; 
      my $ip = qr/\b0+\.0+\.0+\.0+\b|(?:[^\d*]|^)$octet(?:[.]$octet){3}([^\d*]|$)/x;
      
      foreach $str (@ip_list) { 
          print "$str - ";
          print "NO " if $str !~ $ip;
          print "match\n";
      }
      

    OUTPUT:

    1.1.1.1 - match
    123.1.*.* - match
    1.*.3.4 - match
    *.192.2.2 - match
    23.*.3.3 - match
    *.1.23.4 - match
    123.2.*.* - match
    *.*.*.* - match
    *.*.198.20 - match
    
    123.**.23.3 - NO match
    289.2.2.2 - NO match
    21.*.*.1000 - NO match
    *.*.*.** - NO match
    
    11.12.13.14 - match
    1.*.3.4 - match
    1.*.3.* - match
    0.00.0.0 - match
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the following test syntax is part of ksh script [[ $PARAM = TRUE ]]
I use the following Perl syntax in my bash script: perl -i –pe 'next
In batch script, I can run an R script with the following syntax: Rterm.exe
I'm trying to get a regex which is able to find the following part
This seems really simple, but I can't get the syntax correct w/ the following
I have encountered the following Java syntax that I don't recognize. This part is
I'm using the following syntax to loop through a list collection: For Each PropertyActor
I found the following syntax as a VB.NET property and I'm trying to convert
I noticed for a while now the following syntax in some of our code:
Is there a functional difference between the following syntax... [Foo, Bar] public class Baz

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.