Skip to content

Instantly share code, notes, and snippets.

@lobrien
Created August 13, 2019 22:27
Show Gist options
  • Save lobrien/87c5724aec0cc4e8151544b2ff98eda8 to your computer and use it in GitHub Desktop.
Save lobrien/87c5724aec0cc4e8151544b2ff98eda8 to your computer and use it in GitHub Desktop.
Regex template for F#
open System.Text.RegularExpressions
// Seems to be a good capturing pattern, it's "Capture everything not in the list (that is ['?']) until the closing )
/*
\(([^?]+)\)
*/
Regex.Matches (cref, "(([^?=&]+))") |> Seq.head |> fun mtch -> mtch.Value
// So output of Matches is Match seq (I think an array) and then you work on that.
let cref = "Android.Views.View.PerformHapticFeedback(Android.Views.FeedbackConstants, Android.Views.FeedbackFlags)"
Regex.Matches (cref, "\(([^?=&]+)\)") |> Seq.head |> fun mtch -> mtch.Groups.[1] |> fun capture -> capture.Value;;
val it : string =
"Android.Views.FeedbackConstants, Android.Views.FeedbackFlags"
// Note the use of .Groups[1]! .Groups[0] is the match itself!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment