단어 (사용하는 경우 다음의 양쪽에 공백이나 특수 문자가있을 수 있습니다) :세미 팬시 Regex.Replace() 함수
대시 (-), 슬래시 느낌표 점 (!), 줄임표 (... OR ...) (다른 점)
나는 일종의 수렁에 빠져있다. (나는), 콜론 (:), 마침표 (?), 물음표 이 수수께끼에서 나는 문자 그대로 내 검색에서 찾으려고 노력하고있는 모든 특수한 정규 표현식 문자 때문에. Regex.Escape를 사용할 수 있다고 믿습니다.이 경우에는 지금 당장은 작동하지 않습니다. 문자열을 시작
몇 가지 예는 다음과 같을 수 있습니다로 변경 :
private static string[] postCaps = { "-", "/", ":", "?", "!", "...", "…"};
private static string ReplacePostCaps(string strString)
{
foreach (string postCap in postCaps)
{
strString = Regex.Replace(strString, Regex.Escape(postCap), "/(?<=(" + Regex.Escape(postCap) + "))./", RegexOptions.IgnoreCase);
}
return strString;
}
가 대단히 감사합니다 :
여기Change this:
This is a dash - example
To this:
This is a dash - Example <--capitalize "Example" with Regex
This is another dash -example
This is another dash -Example
This is an ellipsis ... example
This is an ellipsis ... Example
This is another ellipsis …example
This is another ellipsis …Example
This is a slash/example
This is a slash/Example
This is a question mark ? example
This is a question mark ? Example
내가 지금까지 가지고있는 코드입니다!
코드를 표시하십시오. – tnw
대문자로 바꾸려면 대체 콜백이있는 Regex.Replace() 메서드 버전이 필요합니다. – nhahtdh
이 튜토리얼을 통해 몇 시간을 보냅니다. http://www.regular-expressions.info/tutorial.html 무거운 곳이지만 정규식 엔진이 실제로 패턴을 사용하여 수행하는 작업에 대해 자세하게 설명합니다. – RobH