欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

首頁綜合 正文
目錄

柚子快報(bào)邀請碼778899分享:替換正則表達(dá)式c#

柚子快報(bào)邀請碼778899分享:替換正則表達(dá)式c#

http://yzkb.51969.com/

1、替換最后一個字符

??? dto.ContactPerson = dto.ContactPerson.ReplaceName("*");

??? ///

??? /// 替換最后一個字符串 ??? /// ??? /// ??? /// ??? /// ??? public static string ReplaceName(this string oldStr, string newStr) ??? { ??????? string pattern = @"(.)$"; ??????? string result = Regex.Replace(oldStr, pattern, newStr);

??????? return result; ??? }

2、替換除第一字符外其他都替換成*

??????? 注意:new string('*', m.Groups[2].Length) 是表示根據(jù)第一個字符后又幾個字符來生成相應(yīng)得*號來替換

?dto.ContactPerson = dto.ContactPerson.ReplaceName();

??? ///

??? /// 替換第一個字符后得其他字符串 ??? /// ??? /// ??? /// ??? /// ??? public static string ReplaceStr(this string oldStr) ??? { ??????? // 正則表達(dá)式:匹配第一個字符之后的所有字符 ??????? string pattern = "(.)(.*)"; ??????? string result = Regex.Replace(oldStr, pattern, m => m.Groups[1].Value + new string('*', m.Groups[2].Length));

??????? return result; ??? }

或則自定義替換成你想要得字符

dto.ContactPerson = dto.ContactPerson.ReplaceStr('-');

??? ///

??? /// 替換第一個字符后得其他字符串 ??? /// ??? /// ??? /// ??? /// ??? public static string ReplaceStr(this string oldStr, char newStr) ??? { ??????? // 正則表達(dá)式:匹配第一個字符之后的所有字符 ??????? string pattern = "(.)(.*)"; ??????? string result = Regex.Replace(oldStr, pattern, m => m.Groups[1].Value + new string(newStr, m.Groups[2].Length));

??????? return result; ??? }

?

3、隱藏手機(jī)號

???????? dto.ContactNumber = PhoneExtensions.GetPhoneHidden(demand.ContactNumber);

???????? ///

??????? /// 獲取隱藏中間四位的手機(jī)號碼 ??????? /// ??????? /// ??????? /// ??????? public static string GetPhoneHidden(this string phone, bool isValidateTelePhone = true) ??????? { ??????????? //如果固化則不隱藏 ??????????? if (isValidateTelePhone && IsTelePhoneNumber(phone)) ??????????? { ??????????????? return phone; ??????????? } ??????????? return Regex.Replace(phone, "(\\d{3})\\d{4}(\\d{4})", "$1****$2"); ??????? }

??????? ///

? ??????? /// 驗(yàn)證固定電話號碼 ? ??????? /// [3位或4位區(qū)號;區(qū)號可以用小括號括起來;區(qū)號可以省略;區(qū)號與本地號間可以用減號或空格隔開;可以有3位數(shù)的分機(jī)號,分機(jī)號前要加減號] ? ??????? /// ? ??????? /// 待驗(yàn)證的字符串 ? ??????? /// 是否匹配 ? ??????? public static bool IsTelePhoneNumber(string input) ??????? { ??????????? string pattern = @"^(((0\d2|0\d{2})[- ]?)?\d{8}|((0\d3|0\d{3})[- ]?)?\d{7})(-\d{3})?$"; ??????????? return IsMatch(input, pattern); ??????? }

柚子快報(bào)邀請碼778899分享:替換正則表達(dá)式c#

http://yzkb.51969.com/

推薦文章

評論可見,查看隱藏內(nèi)容

本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場。

轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/19050956.html

發(fā)布評論

您暫未設(shè)置收款碼

請?jiān)谥黝}配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問

文章目錄