중간 단어가 "is"인 각 단어 사이에 한 단어 씩 정확히 3 단어로 문장을 일치시키는 정규식을 작성하려고합니다. 입력은 입력 문자열 인 경우문자열 시작 부분에 일치하지 않는 경우 정규 표현식과 일치하지 않습니다.
"This is good"
그것은 일치하지 않아야 경우
는 예를 들어, 정규식
"This this is good"
이 내가 지금 노력하고 무엇 일치해야한다 :
는string text = "this is good";
string queryFormat = @"(?<pronoun>[A-Za-z0-9]+) is (?<adjective>[A-Za-z0-9]+)$";
Regex pattern = new Regex(queryFormat, RegexOptions.IgnoreCase);
Match match = pattern.Match(text);
var pronoun = match.Groups["pronoun"].Value; //Should output "this"
var adjective = match.Groups["adjective"].Value; //should output "good"
위의 정규식은 문자열 "는이 좋다"
0 일치무엇이 잘못 되었나요?
당신은 아마 번호와 일치하지 않습니다. [A-Za-z0-9]는 [A-Za-z]이어야합니다. – Tormod