一段Js的正则匹配替换功能、怎样转化为.net后端的代码?

如下代码片、在Js里能实现、但在后台我怎样写都不对呀、大佬带带我。。。

var title = "转入在建申请:项目【蜜蜂巢-厦门13812345678】,申请人:管理员,说明:dsaasddasadsa"

            

var newTitle = title.replace(/(13|14|15|17|18)[0-9]{1}[0-9]{8}/g,function (phoneNum){

    let needHide = phoneNum.substr(3,6)

                

    return phoneNum.replace(needHide,'******')

                

})


console.log(newTitle) 


饮歌长啸
浏览 411回答 1
1回答

侃侃无极

matches part of a string:Regex.IsMatch(subjectString, "(13|14|15|17|18)[0-9]{1}[0-9]{8}", RegexOptions.IgnoreCase | RegexOptions.Multiline)or get the part of a string:Regex.Match(subjectString, "(13|14|15|17|18)[0-9]{1}[0-9]{8}", RegexOptions.IgnoreCase | RegexOptions.Multiline).Valuemaybe your are iterate over all matches in a string:try {    var regexObj = new Regex("(13|14|15|17|18)[0-9]{1}[0-9]{8}", RegexOptions.IgnoreCase | RegexOptions.Multiline);    Match matchResults = regexObj.Match(subjectString);    while (matchResults.Success) {        // doing        matchResults = matchResults.NextMatch();    } } catch (ArgumentException ex) {    // Syntax error in the regular expression}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript