[plt-dev] Racket web page

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon May 24 10:45:21 EDT 2010

This is a great example. Unfortunately, I don't think works to fit into
7 lines by using so many columns.

Here's my attempt to squeeze it into 7 narrow lines, but it loses a
lot, and it's still too wide to fit in the current format:

 #lang racket
 (require net/url net/uri-codec)
 (let* ([url ((compose string->url string-append)
              "http://www.google.com/search?q="
              (uri-encode "racket language"))]
        [rx #rx"(?<=<h3 class=\"r\">).*?(?=</h3>)"])
   (regexp-match* rx (get-pure-port url)))


At Mon, 24 May 2010 14:30:41 +0100, Noel Welsh wrote:
> Fun with net and regular expressions:
> 
> #lang racket
> (require net/url net/uri-codec)
> (define (let-me-google-that-for-you term)
>   (define google-url
>     (string->url (string-append "http://www.google.com/search?q="
> (uri-encode term))))
>   (regexp-match* #rx"(?<=<h3 class=\"r\">).*?(?=</h3>)" (get-pure-port
> google-url)))
> (let-me-google-that-for-you "racket language")
> 
> N.


Posted on the dev mailing list.