ahsant ahsant - 1 year ago 81
C# Question

Regular expression - dont match consecutive chars - C#

I have wasted enough time to construct a regular expressions which matches.

  1. starts with [a-z]+

  2. ends with [a-z]+

  3. in between can have ' or - or both, as many times as user likes ['-]*

  4. ' should not be consecutive, similarly - should not be consecutive.

thanks for any help in advance.

vks vks
Answer Source

You can add lookahead for the same.See demo.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download