regex - Regular expression that accepts alphanumeric , non consecutive dash and non consecutive white space -



regex - Regular expression that accepts alphanumeric , non consecutive dash and non consecutive white space -

can help me create regular look accepts alphanumeric (numbers , letters only) , dashes , white spaces.

it shouldn't take consecutive dashes , consecutive white spaces. or dash followed white space , vice versa. should begin , end alphanumeric characters well.

thank much. help much appreciated. (^-^)v

'abcde' , '324 3a-32' : valid '-' , '324 3a - 32' , '-2323 d-', 'z- -a' : invalid

thanks guys help. v(",)\

try this:

^[a-za-z0-9]+(?:[\s-][a-za-z0-9]+)*$

when first [a-za-z0-9]+ runs out of letters , digits, [\s-] within grouping tries match hyphen or whitespace character. if succeeds, sec [a-za-z0-9]+ tries match more alphanumerics. , grouping gets repeated many times necessary.

regex

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -