Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Created December 3, 2017 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasily-kirichenko/2c3da667178c693a8cb5a39cfd34f3f6 to your computer and use it in GitHub Desktop.
Save vasily-kirichenko/2c3da667178c693a8cb5a39cfd34f3f6 to your computer and use it in GitHub Desktop.
open System.Diagnostics
open System.Text.RegularExpressions
open System.IO
open System
let search file pattern =
let r = Regex(pattern, RegexOptions.ExplicitCapture ||| RegexOptions.Compiled ||| RegexOptions.IgnoreCase)
let delims = [|';'; '"'; ' '|]
[| for line in File.ReadLines file |> Seq.take 10_000_000 do
match r.Match line with
| m when m.Success ->
yield m.Value.Split(delims, StringSplitOptions.RemoveEmptyEntries) |> String.concat "."
| _ -> () |]
[<EntryPoint>]
let main _ =
let sw = Stopwatch.StartNew()
let results = search @"d:\big.txt" @"\{.*(?<name>Microsoft.*)\|\]"
sw.Stop()
printfn "Found %d lines, Elapsed %O" results.Length sw.Elapsed
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment