mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 06:43:47 +00:00
Initial commit
This commit is contained in:
parent
d0eb68594c
commit
c0d4d11b54
24 changed files with 463 additions and 0 deletions
26
vscode/Chapter07/SharedLibrary/StringExtensions.cs
Normal file
26
vscode/Chapter07/SharedLibrary/StringExtensions.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Packt.Shared
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static bool IsValidXmlTag(this string input)
|
||||
{
|
||||
return Regex.IsMatch(input,
|
||||
@"^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$");
|
||||
}
|
||||
|
||||
public static bool IsValidPassword(this string input)
|
||||
{
|
||||
// minimum of eight valid characters
|
||||
return Regex.IsMatch(input, "^[a-zA-Z0-9_-]{8,}$");
|
||||
}
|
||||
|
||||
public static bool IsValidHex(this string input)
|
||||
{
|
||||
// three or six valid hex number characters
|
||||
return Regex.IsMatch(input,
|
||||
"^#?([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue