Skip to content

Commit

Permalink
Doc test for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Jul 16, 2022
1 parent 1a5bbbf commit 440e760
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/Text/Regex/TDFA.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ import "Text.Regex.TDFA"
= Basics
@
>>> let emailRegex = "[a-zA-Z0-9+.\\_-]+\\@[a-zA-Z-]+\\.[a-z]+"
>>> "my email is firstname-lastname_1974@e-mail.com" =~ emailRegex :: Bool
>>> let emailRegex = "[a-zA-Z0-9+._-]+\\@[-a-zA-Z]+\\.[a-z]+"
>>> "my email is first-name.lastname_1974@e-mail.com" =~ emailRegex :: Bool
True
>>> "invalid@mail@com" =~ emailRegex :: Bool
False
>>> "invalid@mail.COM" =~ emailRegex :: Bool
False
>>> "#@invalid.com" =~ emailRegex :: Bool
False
/-- non-monadic/
λ> \<to-match-against\> '=~' \<regex\>
Expand Down Expand Up @@ -151,6 +157,12 @@ just [a]. The character classes like [:alnum:] are supported over
ASCII only, valid classes are alnum, digit, punct, alpha, graph,
space, blank, lower, upper, cntrl, print, xdigit, word.
@
>>> getAllTextMatches ("john anne yifan" =~ "[[:lower:]]+") :: [String]
["john","anne","yifan"]
@
This package does not provide "basic" regular expressions. This
package does not provide back references inside regular expressions.
Expand Down

0 comments on commit 440e760

Please sign in to comment.