파스칼 문자열 리터럴 입력을 다음 패턴으로 일치 시키려고합니다 : @"^'([^']|(''))*'$"
,하지만 작동하지 않습니다. 이 패턴에 어떤 문제가 있습니까? ,파스칼과 같은 문자열 리터럴 정규 표현식
private void Initialize()
{
MatchingTable = new Dictionary<TokenUnit.TokenType, Regex>();
MatchingTable[TokenUnit.TokenType.Identifier] = new Regex
(
@"^[_a-zA-Z]\w*$",
RegexOptions.Compiled | RegexOptions.Singleline
);
MatchingTable[TokenUnit.TokenType.NumberLiteral] = new Regex
(
@"(?:^\d+$)|(?:^\d+\.\d*$)|(?:^\d*\.\d+$)",
RegexOptions.Compiled | RegexOptions.Singleline
);
}
// ... Here it all comes together
public TokenUnit Scan(String input)
{
foreach(KeyValuePair<TokenUnit.TokenType, Regex> node in this.MatchingTable)
{
if(node.Value.IsMatch(input))
{
return new TokenUnit
{
Type = node.Key
};
}
}
return new TokenUnit
{
Type = TokenUnit.TokenType.Unsupported
};
}
파스칼 급 문자열 리터럴이란 무엇입니까? [This?] (http://en.wikipedia.org/wiki/String_literal#Double-up_escape_sequence) –
일부 입력 문자열과 예상 결과를 표시 할 수 있습니까? – Toto