c# - check if string contains character and number

.net, asp.net, c#, regex

Solution

It can be done with a regular expression:

if (Regex.IsMatch(s, @"-A\d")) { ... }

The `\d` matches any digit.

See it working online: ideone

Problem

How do I check if a string contains the following characters "-A" followed by a number? Ex: thisIsaString-A21 = yes, contains "-A" followed by a number Ex: thisIsaNotherString-AB21 = no, does not contain "-A" followed by a number

Original source