아래 정규식 :
(?<=IMD\+F\+\+:::.*)'(?!\r?\n)
은 당신이 원하는 "추가"아포스트로피와 일치합니다.
Regex regexObj = new Regex(@"(?<=IMD\+F\+\+:::.*)'(?!\r\n)");
Match matchResults = regexObj.Match(subjectString);
while (matchResults.Success) {
// matched text: matchResults.Value
// match start: matchResults.Index
// match length: matchResults.Length
matchResults = matchResults.NextMatch();
}
설명 :
"
(?<= # Assert that the regex below can be matched, with the match ending at this position (positive lookbehind)
IMD # Match the characters “IMD” literally
\+ # Match the character “+” literally
F # Match the character “F” literally
\+ # Match the character “+” literally
\+ # Match the character “+” literally
::: # Match the characters “:::” literally
. # Match any single character that is not a line break character
* # Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
)
' # Match the character “'” literally
(?! # Assert that it is impossible to match the regex below starting at this position (negative lookahead)
\r # Match a carriage return character
? # Between zero and one times, as many times as possible, giving back as needed (greedy)
\n # Match a line feed character
)
"
어떤 정규식 맛 (즉, 어떤 언어)에서? –
아포스트로피를 바꾸시겠습니까? 가져 오는 것은 무엇을 의미합니까? – FailedDev
내가 이것을 좋아할 때 사용할 소프트웨어의 정규 표현식의 맛이 확실하지 않습니다. 바꾸기가 약간 정확하지 않았습니다. IMD + F ++ :::과 마지막 사이의 아포스트로피와 일치해야합니다. ' –