Используя .NET Framework, я пытаюсь заменить символы двойной косой черты в строке одной косой чертой, но, похоже, удаляется лишний символ, и я не знаю почему.
У меня есть строка:
http://localhost:4170/RCRSelfRegistration//Default.aspx
Мое регулярное выражение:
[^(://|:\\\\)](\\\\|//|\\/|/\\)
И возвращаемое значение:
http://localhost:4170/RCRSelfRegistratio/Default.aspx
Вы видите, что n в RCRSelfRegistration было удалено. Я не уверен почему.
/// <summary>
/// Match on double slashes (//, \\, /\, \/) but do not match :// or :\\
/// </summary>
private const string strMATCH = @"[^(://|:\\\\)](\\\\|//|\\/|/\\)";
/// <summary>
/// Replace double slashes with single slash
/// </summary>
/// <param name="strUrl"></param>
/// <returns></returns>
public static string GetUrl(string strUrl)
{
string strNewUrl
System.Text.RegularExpressions.Regex rxReplace =
new System.Text.RegularExpressions.Regex(strMATCH);
strNewUrl = rxReplace.Replace(strUrl, "/");
return strNewUrl;
}