Getting Variable to Printf Outside of Closed Functions

What needs to happen for this regular expression and Seq combinations to IO:

let str = File.ReadAllText “input.csv”
let str = Regex.Matches(str, “.+”)
str |> Seq.cast |> Seq.iter (fun i → printf “%s” i)

Your i in the final expression is a Match object instead of a string. You can get the .Value from a Match to get the string it matched. The Seq.cast isn’t necessary. So change your last line to
str |> Seq.iter (fun i -> printf "%s" i.Value)

Should i.Value be a binded expression that can be resused at this point? I tried using various familiar methods to expand on this helper subroutine. What capture method do I have to use for a relative regex Matches group collection?

That’s more of a preference question and depends on the situation. I would think it looks silly to just see
str |> Seq.iter (fun i -> let v = i.Value in printf "%s" v)
but if you reuse it a bunch of times then it can be worth doing.

What capture method do I have to use for a relative regex Matches group collection?

I think you’re asking about Regex captures. For any match, you can access .Groups[captureID] to grab the captured value. Groups[0] is always the whole match, so captureIDs start at 1.

Honestly, I strongly recommend you just play around with Regex in the FSI. To answer this question, I just did dotnet fsi, and

open System.Text.RegularExpressions
let matches = Regex.Matches("a1b2c3\nd4e5f6", "(\w(\d))");;

and just started exploring the matches variable to see what it contained. The .NET Regex class is a bit complicated, and it’s unlikely you’re going to be able to do what you want with it without some exploration.

Dependent on a resuable quotent I want to employ the typical for loop next… Added, I see an effectiveness keeping those regexs written this way, going, without having to break into another file system related operation. However, is there a helper that you know that works similar to the helpers you’ve previously shown?

I don’t know if it’s builtin to any libraries, but I’ve definitely taken this Regex Active Pattern and copy-pasted it into my codebases before because I’ve found it so helpful.

i.Value as a binding method doesn’t work in Visual Studio. Is List.iter more convenient to work with than Seq.iter for any apparent reason for reusable result variables?

Here’s another example of a permeation function that uses Seq.iter that I would like to make more extensive, but needs to be addendumed with a slightly more advanced IO method:

let t = [ ["a";"b";]; ["d";"c";]; ] 

let rec c cp =
    match cp with
    | t::[] -> List.fold (fun acc e -> [e]::acc) [] t
    | t::z ->  List.fold (fun x ce -> (List.fold (fun acc e -> (e::ce)::acc) [] t) @ x) [] (c z)
    | _ -> [] 

let test = c t

test |> Seq.iter (printfn "\n%A")

Neither i.Value or i.Value.ToString() or i.ToString() bindings work to pipe data using Seq.iter.