Regular expressions

Currently Browsing Category 'Regular expressions'

Regular Expressions in C#

by Joseph on Jul 18th in C#, Regular expressions

I needed to validate a form for numeric and integer fields. The C-Sharp Corner seems to cover Regular Expressions pretty well in this article. Essentially, I created a new class named RegularExpressions and added the following: using System.Text.RegularExpressions; // Function to test for Positive Integers.public bool IsNaturalNumber(String strNumber){Regex objNotNaturalPattern=new Regex(“[^0-9]”);Regex objNaturalPattern=new Regex(“0*[1-9][0-9]*”);return !objNotNaturalPattern.IsMatch(strNumber) &&objNaturalPattern.IsMatch(strNumber);}// Function […]

Powered By Wordpress Designed By Ridgey