Не понимаю в чём проблема , тут нормально ищет.
А в Unity ругается:
ArgumentException: parsing "[\/]+[Resources\/Icon\/]+[0-9a-zA-Z]{5,30}+[.]+[0-9a-zA-Z]{1,10}" - Bad quantifier.
Parameter name: [\/]+[Resources\/Icon\/]+[0-9a-zA-Z]{5,30}+[.]+[0-9a-zA-Z]{1,10}
System.Text.RegularExpressions.Syntax.Parser.ParseGroup (System.Text.RegularExpressions.Syntax.Group group, RegexOptions options, System.Text.RegularExpressions.Syntax.Assertion assertion)
System.Text.RegularExpressions.Syntax.Parser.ParseRegularExpression (System.String pattern, RegexOptions options)
System.Text.RegularExpressions.Regex.CreateMachineFactory (System.String pattern, RegexOptions options)
System.Text.RegularExpressions.Regex.InitNewRegex ()
System.Text.RegularExpressions.Regex.Init ()
Сама функция trimLink()
:
void trimLink() {
string URLiconObj="D:/Unity/terranetools.git/Assets/Resources/Icon/C0092173000.png";
string pattern = @"[\/]+[Resources\/Icon\/]+[0-9a-zA-Z]{5,30}+[.]+[0-9a-zA-Z]{1,10}";
var result = Regex.Matches(URLiconObj, pattern).Cast<Match>().ToList();
if(result.Count>=0) {
URLiconObj = result[0].ToString();
} else {
URLiconObj = "";
}
}
{5,30}+
ругается. Вы сначала пишете «от 5 до 30», а потом «от одного до бесконечности».Regex.Matches
, аRegex.Match
.