Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Adjacent rule

Last post 08-26-2008, 11:50 PM by dipendra. 2 replies.
Sort Posts: Previous Next
  •  08-26-2008, 9:16 PM 45674

    Adjacent rule

    Hi there

    How can i achive this

    I need to add the following rule to this regex  ^[a-zA-Z][\s-'a-zA-Z-]{0,25}$

    Blanks, hyphens and apostrophes must not be adjacent.

     

    Many thanks

    Dipendra

     

     

     

     

  •  08-26-2008, 10:55 PM 45677 in reply to 45674

    Re: Adjacent rule

    Not tested but I'd add something like

    (?!.*[ '-]{2})

    after the '^' at the start.

    This is a negative lookahead that will scan forward for 2 consecutive blanks, apostrophes or hyphens. If it finds any then it will reject the whole pattern

    BTW, I'm asssuming that you mean a blank and a hyphen (for example) cannot be adjacent.

    Susan

  •  08-26-2008, 11:50 PM 45682 in reply to 45674

    Re: Adjacent rule

    Thank you susan, works great

     

    Dipendra

View as RSS news feed in XML