Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pattern matching problem

Status
Not open for further replies.

carlosAlberto

IS-IT--Management
Oct 9, 2001
109
0
0
GB
Hi all,

Having a few problems regarding the folowing pattern matching code:

var ipV4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
var ipArray = IPvalue.match(ipV4Pattern);

if i have IPvalue equal to 3.3.3.3 or 4.4.4.4, it places the value of ipArray to 3.3.3.3,3,3,3,3 & 4.4.4.4,4,4,4,4


I'm puzzled... I think ipV4pattern is set up correctly. It should only accept valid IP addresses. ie. 1-255.1-255.1-255.1-255 (four octets of 1-255)


Thanks.
 
Actually.... please ignore the above. I have narrowed it down to:

if (thisSegment < &quot;1&quot; || thisSegment > &quot;254&quot;) {

thisSegment holds the value 3. This loops through 4 times. If i remove the OR statement it seems to work.

Is there something wrong with the above.
 
Well, for one thing, this doesn't appear to be Perl. If you're looking for JavaScript or VB or something, try the appropriate forum. In any event, I don't think you can compare strings numerically in any language, so using GT/LT on a quoted number probably isn't going to give you what you want. Sincerely,

Tom Anderson
Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top