I have got a text string like this:
test1test
I want to check if it contains at least one digit using a regex.
What would this reg
you could use look-ahead assertion for this:
^(?=.*\d).+$
If anybody falls here from google, this is how to check if string contains at least one digit in C#:
With Regex
if (Regex.IsMatch(myString, @"\d"))
{
// do something
}
Info: necessary to add using System.Text.RegularExpressions
With linq:
if (myString.Any(c => Char.IsDigit(c)))
{
// do something
}
Info: necessary to add using System.Linq
Ref this
SELECT * FROM product WHERE name REGEXP '[0-9]'