欢迎光临
我们一直在努力

老外编的程序(三)--正则表达式的Demo-.NET教程,C#语言

建站超值云服务器,限时71元/月

using system.text.regularexpressions;

class test {
    static string captext(match m) {
    // get the matched string
    string x = m.tostring();
    // if the first char is lower case
    if (char.islower(x[0])) {
        // capitalize it
        return char.toupper(x[0]) + x.substring(1, x.length-1);
    }
    return x;
    }
    
    static void main() {
    string text = "four score and seven years ago";
    system.console.writeline("text=[" + text + "]");
    string result = regex.replace(text, @"\w+",
                      new matchevaluator(test.captext));
    system.console.writeline("result=[" + result + "]");
    }
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 老外编的程序(三)--正则表达式的Demo-.NET教程,C#语言
分享到: 更多 (0)