Skip to content

Commit 8977149

Browse files
committed
Fix #50: haddock rendering of code examples with escapes in strings
1 parent e09bc46 commit 8977149

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/Text/Regex/TDFA.hs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import "Text.Regex.TDFA"
3131
3232
= Basics
3333
34-
@
3534
>>> let emailRegex = "[a-zA-Z0-9+._-]+\\@[-a-zA-Z]+\\.[a-z]+"
3635
>>> "my email is [email protected]" =~ emailRegex :: Bool
3736
True
@@ -45,6 +44,7 @@ False
4544
>>> "#@invalid.com" =~ emailRegex :: Bool
4645
False
4746
47+
@
4848
/-- non-monadic/
4949
λ> \<to-match-against\> '=~' \<regex\>
5050
@@ -69,66 +69,61 @@ type you want, especially if you're trying things out at the REPL.
6969
@
7070
/-- returns empty string if no match/
7171
a '=~' b :: String /-- or ByteString, or Text.../
72+
@
7273
7374
>>> "alexis-de-tocqueville" =~ "[a-z]+" :: String
7475
"alexis"
7576
7677
>>> "alexis-de-tocqueville" =~ "[0-9]+" :: String
7778
""
7879
79-
@
80-
8180
== Check if it matched at all
8281
8382
@
8483
a '=~' b :: Bool
84+
@
8585
8686
>>> "alexis-de-tocqueville" =~ "[a-z]+" :: Bool
8787
True
8888
89-
@
90-
9189
== Get first match + text before/after
9290
9391
@
9492
/-- if no match, will just return whole/
9593
/-- string in the first element of the tuple/
9694
a =~ b :: (String, String, String)
95+
@
9796
9897
>>> "alexis-de-tocqueville" =~ "de" :: (String, String, String)
9998
("alexis-","de","-tocqueville")
10099
101100
>>> "alexis-de-tocqueville" =~ "kant" :: (String, String, String)
102101
("alexis-de-tocqueville","","")
103102
104-
@
105-
106103
== Get first match + submatches
107104
108105
@
109106
/-- same as above, but also returns a list of just submatches./
110107
/-- submatch list is empty if regex doesn't match at all/
111108
a '=~' b :: (String, String, String, [String])
109+
@
112110
113111
>>> "div[attr=1234]" =~ "div\\[([a-z]+)=([^]]+)\\]" :: (String, String, String, [String])
114112
("","div[attr=1234]","",["attr","1234"])
115113
116-
@
117-
118114
== Get /all/ matches
119115
120116
@
121117
/-- can also return Data.Array instead of List/
122118
'getAllTextMatches' (a '=~' b) :: [String]
119+
@
123120
124121
>>> getAllTextMatches ("john anne yifan" =~ "[a-z]+") :: [String]
125122
["john","anne","yifan"]
126123
127124
>>> getAllTextMatches ("* - . a + z" =~ "[--z]+") :: [String]
128125
["-",".","a","z"]
129126
130-
@
131-
132127
= Feature support
133128
134129
This package does provide captured parenthesized subexpressions.
@@ -160,11 +155,9 @@ just [a]. The character classes like [:alnum:] are supported over
160155
ASCII only, valid classes are alnum, digit, punct, alpha, graph,
161156
space, blank, lower, upper, cntrl, print, xdigit, word.
162157
163-
@
164158
>>> getAllTextMatches ("john anne yifan" =~ "[[:lower:]]+") :: [String]
165159
["john","anne","yifan"]
166160
167-
@
168161
169162
This package does not provide "basic" regular expressions. This
170163
package does not provide back references inside regular expressions.

0 commit comments

Comments
 (0)