@@ -8,10 +8,10 @@ same kind of regular expressions accepted by JavaScript](https://developer.mozil
88# Match
99@docs Match
1010
11−### Find and Replace
12−@docs contains, find, findN, replace, replaceN
11+# Find and Replace
12+@docs contains, find, findAll, replace, replaceAll
1313
14−### Split
14+# Split
1515@docs split, splitN
1616
1717-}
@@ -40,11 +40,13 @@ caseInsensitive = Native.Regex.caseInsensitive
4040
4141{-| Check to see if a Regex is contained in a string.
4242
43− contains (pattern "123") "12345" == True
44− contains (pattern "b+") "aabbcc" == True
43+```haskell
44+ contains (pattern "123") "12345" == True
45+ contains (pattern "b+") "aabbcc" == True
4546
46− contains (pattern "789") "12345" == False
47− contains (pattern "z+") "aabbcc" == False
47+ contains (pattern "789") "12345" == False
48+ contains (pattern "z+") "aabbcc" == False
49+```
4850-}
4951contains : Regex -> String -> Bool
5052contains = Native.Regex.contains
@@ -63,63 +65,69 @@ Here are details on each field:
6365 * `number` — if you find many matches, you can think of each one
6466 as being labeled with a `number` starting at one. So the first time you
6567 find a match, that is match `number` one. Second time is match `number` two.
66− This is useful when paired with `replace` if replacement is dependent on how
68+ This is useful when paired with `replaceAll` if replacement is dependent on how
6769 many times a pattern has appeared before.
6870-}
6971type Match = { match : String, submatches : [Maybe String], index : Int, number : Int }
7072
7173{-| Find all of the matches in a string:
7274
73− words = find (pattern "\\w+") "hello world"
75+```haskell
76+ words = findAll (pattern "\\w+") "hello world"
7477
75− map .match words == ["hello","world"]
76− map .index words == [0,6]
78+ map .match words == ["hello","world"]
79+ map .index words == [0,6]
7780
78− places = find (pattern "[oi]n a (\\w+)") "I am on a boat in a lake."
81+ places = findAll (pattern "[oi]n a (\\w+)") "I am on a boat in a lake."
7982
80− map .match places == ["on a boat", "in a lake"]
81− map .submatches places == [ [Just "boat"], [Just "lake"] ]
83+ map .match places== ["on a boat", "in a lake"]
84+ map .submatches places == [ [Just "boat"], [Just "lake"] ]
85+```
8286-}
83−find : Regex -> String -> [Match]
84−find = Native.Regex.find
87+findAll : Regex -> String -> [Match]
88+findAll = Native.Regex.findAll
8589
86−{-| Same as `find`, but `findN` will quit searching after the Nth match.
90+{-| Same as `findAll`, but `find` will quit searching after the *n<sup>th</sup>* match.
8791That means the resulting list has maximum length N, but *it can be shorter*
8892if there are not that many matches in the given string.
8993-}
90−findN : Int -> Regex -> String -> [Match]
91−findN = Native.Regex.findN
94+find : Int -> Regex -> String -> [Match]
95+find = Native.Regex.find
9296
9397{-| Replace all matches. The function from `Match` to `String` lets
9498you use the details of a specific match when making replacements.
9599
96− vowels = caseInsensitive (pattern "[aeiou]")
97− devowel = replace vowels (\_ -> "")
100+```haskell
101+ devowel = replaceAll (pattern "[aeiou]") (\_ -> "")
98102
99− devowel "The quick brown fox" == "Th qck brwn fx"
103+ devowel "The quick brown fox" == "Th qck brwn fx"
100104
101− word = pattern "\\w+"
102− reverseWords = replace word (\{match} -> String.reverse match)
105+ reverseWords = replaceAll (pattern "\\w+") (\{match} -> String.reverse match)
103106
104− reverseWords "deliver mined parts" == "reviled denim strap"
107+ reverseWords "deliver mined parts" == "reviled denim strap"
108+```
105109-}
106−replace : Regex -> (Match -> String) -> String -> String
107−replace = Native.Regex.replace
110+replaceAll : Regex -> (Match -> String) -> String -> String
111+replaceAll = Native.Regex.replaceAll
108112
109−{-| Same as `replace`, but `replaceN` will quit after the Nth match.-}
110−replaceN : Int -> Regex -> (Match -> String) -> String -> String
111−replaceN = Native.Regex.replaceN
113+{-| Same as `replaceAll`, but `replace` will quit after the *n<sup>th</sup>* match.-}
114+replace : Int -> Regex -> (Match -> String) -> String -> String
115+replace = Native.Regex.replace
112116
113117{-| Split a string, using the regex as the separator.
114118
115− split (pattern ", ?") "a,b, c, d" == ["a","b","c","d"]
119+```haskell
120+ split (pattern " *, *") "a ,b, c,d" == ["a","b","c","d"]
121+```
116122-}
117123split : Regex -> String -> [String]
118124split = Native.Regex.split
119125
120−{-| Same as `split` but stops after the Nth match.
126+{-| Same as `split` but stops after the *n<sup>th</sup>* match.
121127
122− splitN 1 (pattern ", ?") "a,b,c,d" == ["a","b,c,d"]
128+```haskell
129+ splitN 1 (pattern ": *") "tom: 99,90,85" == ["tom","99,90,85"]
130+```
123131-}
124132splitN : Int -> Regex -> String -> [String]
125133splitN = Native.Regex.splitN