mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-14 02:54:16 -04:00
Separate code
rename
This commit is contained in:
25
Unity Studio/Unity Studio Classes/StringExtensions.cs
Normal file
25
Unity Studio/Unity Studio Classes/StringExtensions.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Unity_Studio
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares the string against a given pattern.
|
||||
/// </summary>
|
||||
/// <param name="str">The string.</param>
|
||||
/// <param name="pattern">The pattern to match, where "*" means any sequence of characters, and "?" means any single character.</param>
|
||||
/// <returns><c>true</c> if the string matches the given pattern; otherwise <c>false</c>.</returns>
|
||||
public static bool Like(this string str, string pattern)
|
||||
{
|
||||
return new Regex(
|
||||
"^" + Regex.Escape(pattern).Replace(@"\*", ".*").Replace(@"\?", ".") + "$",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Singleline
|
||||
).IsMatch(str);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user