Tom Knowlton
asked on
RegEx
I need code in C#.
Code needs to use RegEx to replace all CR (carriage return) characters with "==="
and
replace all LF (line feed) characters with "^^^"
So this:
asdfasdfasdfCRLFasdfasdfas dfsadfCRLF asdfasdfsd a
becomes:
asdfasdfasdf===^^^asdfasdf asdfsadf== =^^^asdfas dfsda
Thanks!!!
Tom
Code needs to use RegEx to replace all CR (carriage return) characters with "==="
and
replace all LF (line feed) characters with "^^^"
So this:
asdfasdfasdfCRLFasdfasdfas
becomes:
asdfasdfasdf===^^^asdfasdf
Thanks!!!
Tom
ASKER
Does not seem to be working....hmmmm.....
ASKER
public string RemoveInvalidChars(string tempString)
{
string cleanedRecord = String.Empty;
cleanedRecord = Regex.Replace(tempString,@ "\x0d","== =");
cleanedRecord = Regex.Replace(cleanedRecor d,@"\x0a", "^^^");
System.Diagnostics.Debug.W riteLine(" RESULT: " + cleanedRecord);
return cleanedRecord;
}
{
string cleanedRecord = String.Empty;
cleanedRecord = Regex.Replace(tempString,@
cleanedRecord = Regex.Replace(cleanedRecor
System.Diagnostics.Debug.W
return cleanedRecord;
}
You must use \x000D for CR and \x000A for LF
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Agreed :)
Bob
Bob
using System.Text.RegularExpress
...
string text = "asdfasdfasdfCRLFasdfasdfa
Console.WriteLine(text);
string newText = Regex.Replace(Regex.Replac
Console.WriteLine(newText)