mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2025-12-06 05:32:03 +01:00
16 lines
357 B
C#
16 lines
357 B
C#
using System.Text.RegularExpressions; // to get Regex
|
|
|
|
namespace Packt.Shared;
|
|
|
|
public static class StringExtensions
|
|
{
|
|
public static bool IsValidEmail(this string input)
|
|
{
|
|
// use a simple regular expression to check
|
|
// that the input string is a valid email
|
|
|
|
return Regex.IsMatch(input,
|
|
@"[a-zA-Z0-9\.-_]+@[a-zA-Z0-9\.-_]+");
|
|
}
|
|
}
|