天天看點

把字元串每隔四個字元使用“-”中橫線分隔的方法

string upstr = Regex.Replace(str, @"(\w{4}(?=[^$]))", "$1-");      

注意引用:using System.Text.RegularExpressions;

比如:74B87337454200D4D33F80C4663DC5E5運用它後就變成:74B8-7337-4542-00D4-D33F-80C4-663D-C5E5

學習交流群:364976091