1
0
mirror of synced 2024-11-24 04:20:10 +01:00
TaikoSoundEditor/Commons/Extensions/StringExtensions.cs

21 lines
480 B
C#
Raw Normal View History

2023-10-01 18:40:41 +02:00
using System.Text.RegularExpressions;
2023-07-17 10:20:00 +02:00
2023-10-01 18:40:41 +02:00
namespace TaikoSoundEditor.Commons.Extensions
2023-07-17 10:20:00 +02:00
{
internal static class StringExtensions
{
public static Match Match(this string s, string regex, string options="")
{
var opts = RegexOptions.None;
2023-10-01 18:40:41 +02:00
if (options.Contains("i")) opts |= RegexOptions.IgnoreCase;
2023-07-17 10:20:00 +02:00
var r = new Regex(regex);
if (!r.IsMatch(s)) return null;
return r.Match(s);
}
}
}