Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从字符串中删除以下格式的电话号码?
xxx-xxxxxxx 或 xxx-xxx-xxxx 或 xxxxxxxxxx
其中 x 是任意数字。
这应该有助于:
var myRegex = new Regex(@"((\d){3}-1234567)|((\d){3}\-(\d){3}\-4567)|((\d){3}1234567)"); string newStringWithoutPhoneNumbers = myRegex.Replace("oldStringWithPhoneNumbers", string.Empty);