Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Trim to remove back slash 1

Status
Not open for further replies.

Bujitsu

MIS
Oct 23, 2003
67
AU
Hi,

Another question:

How can I remove the back slash char from the end of a Syslog line?
It is not visible, so I think it might be CR or LF. But I am unsure in which way to use Trim.

Thanks
 
Use a hex editor to open the syslog file and find the "slash" at the end of the file. Look to see what the character is in hex. For example, if it was a CR and LF the hex codes would be 0D and 0A. Once you have found this value then use the following code.

Code:
//buffer containing the syslog file data
buffer = buffer.TrimEnd('\x0D', '\x0A'); //or whatever character you want to remove

Use this if the only instance of this slash is at the end of the file. If it is throughout the whole file then use something like this.

Code:
buffer = buffer.Replace('\x0D'.ToString(), "");
buffer = buffer.Replace('\x0A'.ToString(), "");

You could also read the file in line by line and trim the character off the end of each line, there are a few different ways of doing this. You just need to find the best way for you. Hope this all helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top