Created
August 13, 2019 22:27
-
-
Save lobrien/87c5724aec0cc4e8151544b2ff98eda8 to your computer and use it in GitHub Desktop.
Regex template for F#
This file contains hidden or 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.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