Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] Need help figuring out special RegExpr rule

Expand Messages
  • flo.gehrke
    ... Alec, That s an interesting alternative to the pattern I posted with... http://tech.groups.yahoo.com/group/ntb-clips/message/22759 on May 28,2012. However,
    Message 1 of 8 , May 10, 2013
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Alec Burgess <buralex@...> wrote:
      >
      > On one line suitable for use in a clip:
      > \b(?=.{0,8}[a-z].{0,8}[a-z])(?=.{0,8}[A-Z].{0,8}[A-Z])(?=.{0,8}[0-9])([a-zA-Z0-9]{8})\b

      Alec,

      That's an interesting alternative to the pattern I posted with...

      http://tech.groups.yahoo.com/group/ntb-clips/message/22759

      on May 28,2012.

      However, it causes some backtracking that you may want to avoid. Tested with Regex Coach against 'tR4HGGUK', your pattern needs 120 steps to achieve a match.

      My proposal of May 2012 -- without Posix character classes and changed a bit...

      \b(?=.*?[a-z].*?[a-z])(?=.*?[A-Z].*?[A-Z])(?=[^\d]*\d)[a-zA-Z0-9]{8}\b

      needs only 45 steps in this case. This could also be written as...

      \b(?=.*?([[:lower:]]).*?(?1))(?=.*?([[:upper:]]).*?(?2))(?=[^\d]*\d.*$)[[:alnum:]]{8}\b

      For checking...

      > This matches: --> "http://somedomain.comx/aaAA112b/index.html"
      > but not ------------> "http://somedomain.comx/Mytrip12/index.html"

      we would have to use...

      http://somedomain.comx/(?=.*?([[:lower:]]).*?(?1))(?=.*?([[:upper:]]).*?(?2))(?=[^\d]*\d.*$)[[:alnum:]]{8}/index.html

      (All patterns in one long line -- no line breaks!)

      Regards,
      Flo
    Your message has been successfully submitted and would be delivered to recipients shortly.