파일 이름 와일드카드 일치 코드
4251 단어 와일드카드
private static bool WildcardMatch(string text, string pattern, bool ignoreCase)
{
if (string.IsNullOrEmpty(pattern))
{
return true;
}
if (string.IsNullOrEmpty(text))
{
foreach (char c in pattern)
{
if (c != '*')
{
return false;
}
}
return true;
}
string regex = "^" + Regex.Escape(pattern).
Replace(@"\*", ".*").
Replace(@"\?", ".") + "$";
if (ignoreCase)
{
Match match = Regex.Match(text, regex, RegexOptions.IgnoreCase);
return match.ToString() == text;
}
else
{
Match match = Regex.Match(text, regex);
return match.ToString() == text;
}
}
<!--
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
-->
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Struts2 학습노트(4) - 와일드카드 사용어댑터는 struts2 설정에서 매우 자주 사용하는 설정 방식이다. 프로그램 개발 과정에서'약속이 설정보다 낫다'는 원칙을 따라야 한다. 이런 원칙에서 약속의 결과가 비교적 적합하면 설정의 수량을 크게 줄이고 설정을...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.