Roy Ashbrook

let go or be dragged
posts - 197, comments - 29, trackbacks - 8

October 2006 Entries

replacing carriage return

nothing fancy here, we're just doing a regex replace on \r and replacing it with nothing. this is a different way of doing the same thing dennis already posted here. =P using System.IO; using System.Text.RegularExpressions; namespace StripCR {     class Program     {         static void Main(string[] args)         {             nocr(args[0]);         }         public static void nocr(string f)         {             string t;             using (StreamReader r = new StreamReader(f))             t = Regex.Replace(r.ReadToEnd(), "\r", "");             using (StreamWriter w = new StreamWriter(f))             w.Write(t);         }     } } and because i know you want to know, here's...

posted @ Tuesday, October 31, 2006 12:08 PM | Feedback (0) | Filed Under [ DEV ]

parsing eml files with ruby

This is essentially the same thing, just with ruby code. Again, note that you can change that URL regular expression to match what you want to find in the email. i also split the file in half after the header and only searched the header for from/to/subject and the body for urls in this one. a slightly different approach. The point of this is really just to show how simple it is to setup the logic and where you can easily configure your regular expressions to tweak your results. As with most ruby code I write, there is probably a...

posted @ Thursday, October 26, 2006 11:18 AM | Feedback (0) | Filed Under [ DEV ]

parsing eml files with c#

here's a short code snippet showing how to parse the from/to/subject from an eml file as well as any urls located in the message. the regex for urls isn't perfect. there are a million ways to do url regex, so pick your poison from the web. this is just for example. reposted from here. 123456789101112131415161718192021222324252627282930313233343536373839404142434445 using System;using System.IO;using System.Text.RegularExpressions;namespace parse.eml{ class Email { string _path,_to,_from,_subject,_urls; public Email(string path) { ...

posted @ Wednesday, October 25, 2006 12:43 AM | Feedback (0) | Filed Under [ DEV ]

Powered by: