C# Regular Regex Expression to match letters, numbers

This below is code to check only letters and numbers


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Ads.Website.Helper
{
    public class CommonHelper
    {
        public static bool CheckUserName(string username)
        {
            Regex regex = new Regex(@"^[a-zA-Z0-9]+$");
            return regex.IsMatch(username);
        }
    }
}

Reactions

Post a Comment

0 Comments