public static string ChangeParam(string url, string paramName, string value)
{
if (Regex.IsMatch(url, "[?&]" + paramName + "=[^&]*",RegexOptions.IgnoreCase))
{
url = Regex.Replace(url, "(?<s>[?&]" + paramName + "=)[^&]*", "${s}" + value,RegexOptions.IgnoreCase);
}
else if (Regex.IsMatch(url, "[?&]"))
{
url += '&' + paramName + "=" + value;
}
else
{
url += '?' + paramName + "=" + value;
}
return url;
}
{
if (Regex.IsMatch(url, "[?&]" + paramName + "=[^&]*",RegexOptions.IgnoreCase))
{
url = Regex.Replace(url, "(?<s>[?&]" + paramName + "=)[^&]*", "${s}" + value,RegexOptions.IgnoreCase);
}
else if (Regex.IsMatch(url, "[?&]"))
{
url += '&' + paramName + "=" + value;
}
else
{
url += '?' + paramName + "=" + value;
}
return url;
}
/// <summary>
/// 将字符串类型的泘点数或整数乘100,返回整数部分的字符串。
/// 主要用于美元的换算
/// </summary>
/// <param name="floatString"></param>
/// <returns></returns>
public static string FloatMultiplyHundred(string floatString)
{
floatString = floatString.Trim() + "00";
return Regex.Replace(floatString, @"^(?<int>\d+)\.(?<cent>\d{2})\d*$", "${int}${cent}");
}
/// 将字符串类型的泘点数或整数乘100,返回整数部分的字符串。
/// 主要用于美元的换算
/// </summary>
/// <param name="floatString"></param>
/// <returns></returns>
public static string FloatMultiplyHundred(string floatString)
{
floatString = floatString.Trim() + "00";
return Regex.Replace(floatString, @"^(?<int>\d+)\.(?<cent>\d{2})\d*$", "${int}${cent}");
}