Return to Snippet

Revision: 17753
at September 14, 2009 03:13 by manatlan


Initial Code
//==========================================
// REGEX
//==========================================
using System.Text.RegularExpressions;

Regex r = new Regex(@"CES=([^,]+),");
Match m = r.Match(rf);
if (m.Success)
    rf = m.Groups[1].Value;
else
    rf = "";

//==========================================
// TEXT ENCODING (utf8 -> cp1252)
//==========================================
csv = Encoding.GetEncoding("Windows-1250").GetString(Encoding.UTF8.GetBytes( csv ) );

//==========================================
// MAKE A QUICK LOG
//==========================================
private void log(object o)
{
   System.IO.File.AppendAllText("C:/Temp/logmarco4.txt", "-" + Convert.ToString(o)+"\n");
}

//==========================================
// FORMAT Date
//==========================================
String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9/3/2008 16:05:07"

Initial URL


Initial Description


Initial Title
C# tricks : regex, encoding, log, format date

Initial Tags
regex, text

Initial Language
C#