Scripting


  1. dleblanc67
  2. pyuson

This archived discussion is "read only".
For the corresponding "live" discussions, post in the active topic forum here.



Top 1.   Jan 16, 2004 3:01 PM

» dleblanc67 - Script to input IP Address and Subnet Bits (10.3.2.0/28)

I am trying to write an IF statement that will accept and IP address and Subnet Bits in this format:

10.3.2.0/28

I have this one, but it only accepts 10.3.2.1 (as well as www.example.com).

if (($qs =~ /^(\d+\.\d+\.\d+\.\d+)$/) or
($qs =~ /^([a-zA-Z0-9][a-zA-Z0-9\.\-_]*)$/)) {
$qs = $1;

Any suggestions?

-- posted by dleblanc67



Top 2.   Jan 24, 2004 1:56 PM

» pyuson - Re: Script to input IP Address and Subnet Bits (10.3.2.0/28)

In response to message posted by dleblanc67:

Try this:
if ($qs =~ /^([\w\d]+\.[\w\d]+\.[\w\d]+)(\/(\d*))*$/
or $qs =~ /^(\d+\.\d+\.\d+\.\d+)(\/(\d*))*$/ ) {
$qs = $1;
$bits = $3;
}

-- posted by pyuson



Please follow the guidelines set forth in the Suite101 Posting Etiquette when adding to the discussion.