У меня есть этот бит кода, который должен заменить символ строки строки Windows (\r\n
) пустым символом.Regex заменяет символы разрыва строки Windows
Однако, похоже, что это ничего не заменяет, как если бы я рассматривал строку после того, как выражение регулярного выражения было применено к ней, символы очередности все еще существуют.
private void SetLocationsAddressOrGPSLocation(Location location, string locationString)
{
//Regex check for the characters a-z|A-Z.
//Remove any \r\n characters (Windows Newline characters)
locationString = Regex.Replace(locationString, @"[\\r\\n]", "");
int test = Regex.Matches(locationString, @"[\\r\\n]").Count; //Curiously, this outputs 0
int characterCount = Regex.Matches(locationString,@"[a-zA-Z]").Count;
//If there were characters, set the location's address to the locationString
if (characterCount > 0)
{
location.address = locationString;
}
//Otherwise, set the location's coordinates to the locationString.
else
{
location.coordinates = locationString;
}
} //End void SetLocationsAddressOrGPSLocation()