62,025
社区成员
发帖
与我相关
我的任务
分享
//情况一
using System.Text.RegularExpressions;
MatchCollection mc = Regex.Matches(str, @"\d+");
foreach (Match m in mc)
{
Console.WriteLine(m.Value);
}
Console.ReadLine();
//情况二
using System.Text.RegularExpressions;
string result = Regex.Replace(str, @"(?<=\d+)px", "", RegexOptions.IgnoreCase);
Console.WriteLine(result);
Console.ReadLine();
Dim Width As String = "53px"
Dim width As Integer = Integer.Parse(System.Text.RegularExpressions.Regex.Replace(Width, "\D", ""))
string Width = "53px";
int width = int.Parse(System.Text.RegularExpressions.Regex.Replace(Width, @"\D", ""));
string Width = "53px";
int width = int.Parse(Width.Trim('p','x'));
// 或:
int width = int.Parse(Width.TrimEnd('p','x'));
string Width = "53px";
int width = int.Parse(Width.Replace("px", "");