Results 1 to 4 of 4
  1. #1
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default Regex, oh how I love thee...let me count all thy permutations...

    OK so it has been awhile since I had to program anything in regular expression. Now I have to validate that the end user enters a valid IP address. I know how to implement the method that returns the regular expression, and I use the preset character code:

    \d\d\d[.]\d\d\d[.]\d\d[.]\d\d

    However, the last 3 octets MIGHT only be 1 digit...how do you suppose I should compensate for that possibility? Thanks for your help!
    ~MSP430 Lover~

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Joel View Post
    OK so it has been awhile since I had to program anything in regular expression. Now I have to validate that the end user enters a valid IP address. I know how to implement the method that returns the regular expression, and I use the preset character code:

    \d\d\d[.]\d\d\d[.]\d\d[.]\d\d

    However, the last 3 octets MIGHT only be 1 digit...how do you suppose I should compensate for that possibility? Thanks for your help!
    A range? i.e. x{1,3} means 'x one to three times'. b.t.w. those aren't permutations.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default Thanks!

    Quote Originally Posted by JosAH View Post
    A range? i.e. x{1,3} means 'x one to three times'. b.t.w. those aren't permutations.

    kind regards,

    Jos
    Kind regards to YOU , good sir!

    Lamentably I chose the wrong word. They aren't permutations at all. Combinatorics?
    ~MSP430 Lover~

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Joel View Post
    Kind regards to YOU , good sir!

    Lamentably I chose the wrong word. They aren't permutations at all. Combinatorics?
    Nope, they aren't combinations either, sorry for that ;-) Example:

    C(3, 1) == a, b, c
    C(3, 2) == ab, ac, bc
    C(3, 3) == abc
    P(3) == abc, acb, bac, bca, cab, cba

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. help with permutations of a string
    By hoosierfan24 in forum New To Java
    Replies: 8
    Last Post: 05-25-2011, 07:35 PM
  2. Help with Creating Array List of permutations
    By sparklezilla in forum Advanced Java
    Replies: 4
    Last Post: 05-26-2010, 03:30 AM
  3. array permutations
    By mtK in forum Advanced Java
    Replies: 4
    Last Post: 04-08-2010, 06:57 AM
  4. Permutations
    By m00nchile in forum New To Java
    Replies: 3
    Last Post: 03-25-2010, 09:58 PM
  5. Find all permutations of a number
    By matzahboy in forum New To Java
    Replies: 6
    Last Post: 12-02-2008, 04:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •