Created
December 3, 2017 15:43
-
-
Save vasily-kirichenko/2c3da667178c693a8cb5a39cfd34f3f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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