17._5正则表达式的替换
生活随笔
收集整理的這篇文章主要介紹了
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 = @"\bw{3}\.\w+\.(com|net|org)\b";string replacment ="\n"+@"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","\n"+@"http://www.",RegexOptions.IgnoreCase));Regex myregex = new Regex(pattern,RegexOptions.IgnoreCase);string result = myregex.Replace(input, replacment);Console.WriteLine("替換后的字符串3:"+result.ToLower());Console.ReadKey();}}
}
?
轉載于:https://www.cnblogs.com/zqyo2000z/p/5515883.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的17._5正则表达式的替换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 正则表达式的扩展
- 下一篇: 【云计算】使用nsenter进入Dock