Forum Moderators: phranque

Message Too Old, No Replies

More RegEx Syntax

Matching an IP range

         

guillermo5000

6:56 am on Oct 27, 2004 (gmt 0)

10+ Year Member



I am writing a regex to match xx.xx.xx.64 to xx.xx.xx.127 and here us my result:

^xx\.xx\.xx\.(6[4-9]¦[7-9][0-9]¦1[0-2][0-9])$

Is it correct? I realize this also cover 128 and 129 but am I on the right track? Thanks for any wisdom.

jdMorgan

1:04 pm on Oct 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you're on the right track. Ypu can add a bit to the end to get 64-127 exactly:
^xx\.xx\.xx\.(6[4-9]¦[7-9][0-9]¦1[01][0-9]¦12[0-7])$

Jim

guillermo5000

10:48 pm on Oct 27, 2004 (gmt 0)

10+ Year Member



I see, you stopped at 119 and added the last bit to match 120-127.

Thank you VERY much! I may someday have this down.