Previously on How to check if a String contains any letter from a to z? I have learnt how to use Regex to detect letters from a to z.
Can we make Regex to detect any symbols too? Like . , ! ? @ # $ % ^ & * ( ) or any other else.
More specifically, I want to accept only digits in my string.
To match string containing only digits or empty string use regex pattern
^\d*$To match string containing only digits, not allowing an empty string use regex pattern
^\d+$Test this code here.
Learn more at http://www.regular-expressions.info/dotnet.html