This commit is contained in:
Александр Бабаев 2023-08-13 11:13:05 +03:00
parent 4c697863fa
commit e6b2c3f0a1
5 changed files with 28 additions and 7 deletions

View File

@ -1,4 +1,5 @@
using System.Net.Mail; using System.Net.Mail;
using System.Text.RegularExpressions;
namespace anbs_cp.Classes; namespace anbs_cp.Classes;
@ -108,4 +109,26 @@ public static class TextFormatter
return false; 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;
}
} }

View File

@ -68,7 +68,7 @@ public static class TypeConverter
public static string BoolToStr (bool value) => value.ToString(); public static string BoolToStr (bool value) => value.ToString();
/// <summary> /// <summary>
/// Преобразование <see cref="bool"/> в <see cref="string"/> /// Преобразование любого типа в <see cref="string"/> (сериализация)
/// </summary> /// </summary>
/// <typeparam name="T">Тип</typeparam> /// <typeparam name="T">Тип</typeparam>
/// <param name="value">Значение типа</param> /// <param name="value">Значение типа</param>
@ -152,7 +152,7 @@ public static class TypeConverter
bool.TryParse(value, out bool result) ? result : defaultValue; bool.TryParse(value, out bool result) ? result : defaultValue;
/// <summary> /// <summary>
/// Преобразование <see cref="string"/> в тип <see cref="T"/> /// Преобразование <see cref="string"/> в тип <see cref="T"/> (десериализация)
/// </summary> /// </summary>
/// <typeparam name="T">Тип</typeparam> /// <typeparam name="T">Тип</typeparam>
/// <param name="value">Строка</param> /// <param name="value">Строка</param>

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Version>2023.811.0</Version> <Version>2023.813.0</Version>
<Authors>Александр Бабаев</Authors> <Authors>Александр Бабаев</Authors>
<Product>Набор компонентов ANB Software</Product> <Product>Набор компонентов ANB Software</Product>
<Description>Библиотека полезных методов языка C#</Description> <Description>Библиотека полезных методов языка C#</Description>

View File

@ -15,9 +15,11 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0421_043E_0437_0434_0430_0451_043C/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0421_043E_0437_0434_0430_0451_043C/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0432_0435_0434_0451_043D/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0432_0435_0434_0451_043D/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0438_0434_0435_043E_043A_0430_0440_0442_0435/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0438_0434_0435_043E_043A_0430_0440_0442_0435/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0434_0435_0441_0435_0440_0438_0430_043B_0438_0437_0430_0446_0438_044F/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0434_0435_0448_0438_0444_0440_043E_0432_0430_043D_0438_044F/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0434_0435_0448_0438_0444_0440_043E_0432_0430_043D_0438_044F/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0438_043C_0451_043D/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0438_043C_0451_043D/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_043F_0443_0442_0451_043C/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_043F_0443_0442_0451_043C/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0435_0440_0438_0430_043B_0438_0437_0430_0446_0438_044F/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0447_0451_0442/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0447_0451_0442/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0447_0451_0442_0447_0438_043A/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0441_0447_0451_0442_0447_0438_043A/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0445_044D_0448_0430/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=_0445_044D_0448_0430/@EntryIndexedValue">True</s:Boolean>

View File

@ -18,10 +18,6 @@
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\anbs_cposinfo\anbs_cposinfo.csproj" /> <ProjectReference Include="..\anbs_cposinfo\anbs_cposinfo.csproj" />
<ProjectReference Include="..\anbs_cp\anbs_cp.csproj" /> <ProjectReference Include="..\anbs_cp\anbs_cp.csproj" />