I recently came across a site that made coming up with regular expressions much, much easier for me: http://www.debuggex.com/
Hopefully that will help with your "regex hell" problem. On Thursday, July 18, 2013, Greg Hendershott wrote: > To add to what Carl and Robby said: > > On Thu, Jul 18, 2013 at 2:29 AM, <[email protected] <javascript:;>> > wrote: > > (although truth be told, mail headers are surprisingly nonstandard even > > within a single message) > > That's where net/head could definitely help. (Especially for SMTP > headers, which tend to be more "interesting" than typical HTTP > headers.) > > > I eventually discovered that I could sort of cheat, by just wrapping the > > regexp-match function with a car (which worked, because this particular > > list only had one element), and then it was usable from then on (and > > validated true from "string?"). > > It's worth walking through what Carl described. Actually you're lucky, > you have a specific example of something you want to do, which touches > on a few basic aspects of Racket. > > Having said that, one pattern I've settled into using with regexps is > to use `match`, which makes it convenient to "de-structure" the list. > For example: > > (match "From: Me" > [(pregexp "^(.+):\\s*(.+)$" (list all key val)) > (displayln all) ; From: Me > (displayln key) ; From > (displayln val)]) ; Me > > If you don't need the "all" part, you can supply _ like so: > > (match "From: Me" > [(pregexp "^(.+):\\s*(.+)$" (list _ key val)) > (displayln key) > (displayln val)]) > > Which is the pattern I use a lot. > > Again, you probably want to use net/head to deal with the gory details > of SMTP headers as Robby suggested, and it would definitely be good to > walk through the explorations Carl described. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users >
____________________ Racket Users list: http://lists.racket-lang.org/users

