How can I validate a string using Regular Expressions to only allow alphanumeric characters in it?
(I don\'t want to allow for any spaces either).
Use the following expression:
^[a-zA-Z0-9]*$
ie:
using System.Text.RegularExpressions; Regex r = new Regex("^[a-zA-Z0-9]*$"); if (r.IsMatch(SomeString)) { ... }