A: 

http://refactormycode.com

Nick Stinemates
http://refactormycode.com, and they still don't do F#
Benjol
+1  A: 

I'd use an active pattern to encapsulate the Regex.IsMatch and Regex.Match pairs, like so:

let (|Matches|_|) re s =
  let m = Regex(re).Match(s)
  if m.Success then
    Some(Matches (m.Value))
  else
    None

Then your nexttoken function can look like:

let nexttoken (st:String) =         
  match st with        
  | Matches "^s+" s -> Whitespace(s)        
  | Matches "^//.*?\r?\n" s -> Comment(s)
  ...
kvb
I like this! Don't know how I managed to go so long without discovering active patterns. Thanks, I've learnt something new.
Benjol
Why Some(Matches(m.Value)) ? Some(m.Value) works for me.
Benjol
Yeah, looks like Some(m.Value) works fine. If you use total active patterns (which can't fail to match, but can act like discriminated unions), you specify the name of the pattern that matches, so I was doing that here too. It seems like that's not necessary with partial active patterns.
kvb