Skip to main content
added 6 characters in body
Source Link
CodeMonkey
  • 214
  • 1
  • 7

In F# you have the FsVerbalExpressions module. It allows you to compose Regexes from verbal expressions, it also has some pre-built regexes (like URL).

One of the examples for this syntax is the following:

let groupName = "GroupNumber" VerbEx() |> add "COD" |> beginCaptureNamed groupName |> any "0-9" |> repeatPrevious 3 |> endCapture |> then' "END" |> capture "COD123END" groupName |> printfn "%s" // 123 

If you're not familiar with F# syntax, groupName is the string "GroupNumber".

Then they create a Verbal Expression (VerbEx) which they construct as "COD(?[0<GroupNumber>[0-9]{3})END". Which they then test on the string "COD123END", where they get the named capture group "GroupNumber". This results in 123.

I honestly find the normal regex much easier to comprehend.

In F# you have the FsVerbalExpressions module. It allows you to compose Regexes from verbal expressions, it also has some pre-built regexes (like URL).

One of the examples for this syntax is the following:

let groupName = "GroupNumber" VerbEx() |> add "COD" |> beginCaptureNamed groupName |> any "0-9" |> repeatPrevious 3 |> endCapture |> then' "END" |> capture "COD123END" groupName |> printfn "%s" // 123 

If you're not familiar with F# syntax, groupName is the string "GroupNumber".

Then they create a Verbal Expression (VerbEx) which they construct as "COD(?[0-9]{3})END". Which they then test on the string "COD123END", where they get the named capture group "GroupNumber". This results in 123.

I honestly find the normal regex much easier to comprehend.

In F# you have the FsVerbalExpressions module. It allows you to compose Regexes from verbal expressions, it also has some pre-built regexes (like URL).

One of the examples for this syntax is the following:

let groupName = "GroupNumber" VerbEx() |> add "COD" |> beginCaptureNamed groupName |> any "0-9" |> repeatPrevious 3 |> endCapture |> then' "END" |> capture "COD123END" groupName |> printfn "%s" // 123 

If you're not familiar with F# syntax, groupName is the string "GroupNumber".

Then they create a Verbal Expression (VerbEx) which they construct as "COD(?<GroupNumber>[0-9]{3})END". Which they then test on the string "COD123END", where they get the named capture group "GroupNumber". This results in 123.

I honestly find the normal regex much easier to comprehend.

Source Link
CodeMonkey
  • 214
  • 1
  • 7

In F# you have the FsVerbalExpressions module. It allows you to compose Regexes from verbal expressions, it also has some pre-built regexes (like URL).

One of the examples for this syntax is the following:

let groupName = "GroupNumber" VerbEx() |> add "COD" |> beginCaptureNamed groupName |> any "0-9" |> repeatPrevious 3 |> endCapture |> then' "END" |> capture "COD123END" groupName |> printfn "%s" // 123 

If you're not familiar with F# syntax, groupName is the string "GroupNumber".

Then they create a Verbal Expression (VerbEx) which they construct as "COD(?[0-9]{3})END". Which they then test on the string "COD123END", where they get the named capture group "GroupNumber". This results in 123.

I honestly find the normal regex much easier to comprehend.