in reply to A poor bloke and his regex...
Just to add a bit. Your original regex didn't work because you included the first slash as part of a character class. The regex would match a string beginning with a slash or any (other) non-whitespace until it came to a whitespace. This is why INVALID was being removed when you didn't want to. By moving the slash outside the character class, the string only matches when it begins with a slash.