zoukankan      html  css  js  c++  java
  • 17._5正则表达式的替换

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Text.RegularExpressions;
    namespace _17._5正则表达式的替换
    {
        class Program
        {
            static void Main(string[] args)
            {
                string input = "Welcome to ***ww****w*********************";
                string pattern = @"w{3}.w+.(com|net|org)";
                string replacment ="
    "+@"http://$&";
    
                Console.WriteLine("替换前的字符串"+input);
                Console.WriteLine("替换后的字符串");
                Console.WriteLine(Regex.Replace(input,pattern,replacment));
                Console.WriteLine("替换后的字符串1:"+(Regex.Replace(input,pattern,replacment,RegexOptions.IgnoreCase)).ToLower());
                Console.WriteLine("替换后的字符串2:"+Regex.Replace(input,"www","
    "+@"http://www.",RegexOptions.IgnoreCase));
    
    
                Regex myregex = new Regex(pattern,RegexOptions.IgnoreCase);
                string result = myregex.Replace(input, replacment);
                Console.WriteLine("替换后的字符串3:"+result.ToLower());
    
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    PhpStorm如何连接外部服务器

    hello,bokeyuan
    pyspark SparkSession及dataframe基本操作
    spark2.2 中文文档
    广告推荐加入图像特征
    docker教程
    DSSM算法-计算文本相似度
    navivate 下载
    save——model模块保存和载入使用简单例子
  • 原文地址:https://www.cnblogs.com/zqyo2000z/p/5515883.html
Copyright © 2011-2022 走看看