我尝试在特定字符(冒号)“:”后用空格(“”)替换字符串示例:2017 - Alpha Romeo United kingdom : New vehicle (by abc)我想输出为“2017 - Alpha Romeo United kingdom”
2017 - Alpha Romeo United kingdom : New vehicle (by abc)
2017 - Alpha Romeo United kingdom
2exbekwf1#
您可以使用以下 regex*(使用capturing group和positive lookahead)*:
input >> 2017 - Alpha Romeo United kingdom : New vehicle (by abc) regex search >> (?=:):(.*) replace with >> " " output >> 2017 - Alpha Romeo United kingdom
参见demo / explanation
聪明
{ assign var = "articleTitle" value = "2017 - Alpha Romeo United kingdom : New vehicle (by abc)" } { $articleTitle | regex_replace: "/(?=:):(.*)/": " " }
ne5o7dgx2#
private void Form1_Load(object sender, EventArgs e) { string str = "2017 - Alpha Romeo United kingdom : New vehicle (by abc)"; str = Regex.Replace(str, @":+(.*)", ""); MessageBox.Show(str); }
2条答案
按热度按时间2exbekwf1#
您可以使用以下 regex*(使用capturing group和positive lookahead)*:
参见demo / explanation
聪明
ne5o7dgx2#