Dofactory.com
Dofactory.com

How to create a C# Regex that accepts numbers only (0-9) and no characters.

The Regex is: ^[0-9]*$

^ Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled. This matches a position, not a character.

[0-9] Matches a character having a character code between the two specified characters inclusive.

* Matches 0 or more of the preceding token.

$ Matches the end of the string, or the end of a line if the multiline flag (m) is enabled. This matches a position, not a character.



Jack Poorte
Jack Poorte
Last updated on Sep 30, 2023



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.