문자열 설정 -
string str = "Cookie and Session";
다음 정규식을 사용하여 문자열에서 마지막 2자를 가져옵니다 -
Regex.Match(str,@"(.{2})\s*$") 다음은 코드입니다 -
예시
using System;
using System.Text.RegularExpressions;
public class Demo {
public static void Main() {
string str = "Cookie and Session";
Console.WriteLine(Regex.Match(str,@"(.{2})\s*$"));
}
} 출력
on