20230813
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Net.Mail;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace anbs_cp.Classes;
|
||||
|
||||
@@ -108,4 +109,26 @@ public static class TextFormatter
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверяет текст <paramref name="text"/> на совпадение регулярному выражению по шаблону <paramref name="pattern"/> с опциями <paramref name="options"/> (см. <see cref="RegexOptions"/>)
|
||||
/// </summary>
|
||||
/// <param name="text">Текст на проверку</param>
|
||||
/// <param name="pattern">Шаблон</param>
|
||||
/// <param name="options">Параметры проверки в формате <see cref="RegexOptions"/> (можно игнорировать, по умолчанию: <see cref="RegexOptions.None"/>)</param>
|
||||
/// <returns>Есть ли совпадения в тексте</returns>
|
||||
public static bool IsMatchRegExp (string text, string pattern, RegexOptions? options = null)
|
||||
{
|
||||
// Задаю настройки проверки регулярных выражений
|
||||
RegexOptions regexOptions = options ?? RegexOptions.None;
|
||||
|
||||
// Создаю класс для проверки выражения
|
||||
Regex regex = new Regex(pattern, regexOptions);
|
||||
|
||||
// Получаю совпадения
|
||||
MatchCollection matches = regex.Matches(text);
|
||||
|
||||
// Возвращаю результат
|
||||
return matches.Count > 0;
|
||||
}
|
||||
}
|
@@ -68,7 +68,7 @@ public static class TypeConverter
|
||||
public static string BoolToStr (bool value) => value.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// Преобразование <see cref="bool"/> в <see cref="string"/>
|
||||
/// Преобразование любого типа в <see cref="string"/> (сериализация)
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Тип</typeparam>
|
||||
/// <param name="value">Значение типа</param>
|
||||
@@ -152,7 +152,7 @@ public static class TypeConverter
|
||||
bool.TryParse(value, out bool result) ? result : defaultValue;
|
||||
|
||||
/// <summary>
|
||||
/// Преобразование <see cref="string"/> в тип <see cref="T"/>
|
||||
/// Преобразование <see cref="string"/> в тип <see cref="T"/> (десериализация)
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Тип</typeparam>
|
||||
/// <param name="value">Строка</param>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Version>2023.811.0</Version>
|
||||
<Version>2023.813.0</Version>
|
||||
<Authors>Александр Бабаев</Authors>
|
||||
<Product>Набор компонентов ANB Software</Product>
|
||||
<Description>Библиотека полезных методов языка C#</Description>
|
||||
|
Reference in New Issue
Block a user