Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is there any difference between these RegEx patterns?

    I'd like to validate input of a classid - registry key value:
    "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" -- where "x" is a hex-digit.

    pattern-1:

    /{{1}[0-9A-F]{8}-{1}[0-9A-F]{4}-{1}[0-9A-F]{4}-{1}[0-9A-F]{4}-{1}[0-9A-F]{12}}{1}/i

    pattern-2:

    /{{1}[\dA-F]{8}-{1}[\dA-F]{4}-{1}[\dA-F]{4}-{1}[\dA-F]{4}-{1}[\dA-F]{12}}{1}/i

    pattern-3:

    /{{1}[0-F]{8}-{1}[0-F]{4}-{1}[0-F]{4}-{1}[0-F]{4}-{1}[0-F]{12}}{1}/i

    - just want to know if the shortest one is best... or if this can be further condensed.

    <edit>fixed a mistake in the last one </edit>
    Last edited by swmr; 01-03-2004 at 08:55 AM.
    hmm... ?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you go [0-F] ? I think that has to be [0-9A-F].

    Those {1} are certainly unecessary, and you could probably loop the middle bit if ([blah]{n}){n} is allowed .. so:
    Code:
    /{[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}}/i
    i'm typing off the top of my head here .. haven't tested it ..
    Last edited by brothercake; 01-03-2004 at 12:09 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey now, that seems to work... & much shorter too!

    - didn't expect the [0-F] to fly, but I can't make it miss either... are there any characters between [0-9] & [A-F] that could sneak in there?
    hmm... ?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in a classid? I'm not sure ... don't think so
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ah, I found the ASCII range: [0123456789:;<=>?@ABCDEF]...

    so, [0-F] would allow these non-hex characters to validate [: ; < = > ? @]

    oops
    hmm... ?

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh right .. I didn't realise you can span whole ASCII ranges, I though it was in discrete sets of numbers and letters.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

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