summaryrefslogtreecommitdiff
path: root/EXAMPLES
blob: 4f8980040c9f109c6c320c8ad3fdd88d552d9a6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
regexqq - EXAMPLES
----------------------------------------------------------------------------------------

-- Here is a pasteable-into-ghci version of the below:

:m + Text.Regex.PCRE.QQ
[$rx|([aeiou]).*(er|ing|tion)([\.,!\?]*)$|] "helloing.!?!?!"
[$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
tail `fmap` [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
return . tail =<< [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
maybe [] tail $ [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
maybe [] tail $ [$rx|^([+-])?([0-9]+)\.([0-9]+)(.*)$|] (show (negate pi) ++ "asdx")

----------------------------------------------------------------------------------------

ghci> :m + Text.Regex.PCRE.QQ

ghci> [$rx|([aeiou]).*(er|ing|tion)([\.,!\?]*)$|] "helloing.!?!?!"
Just ["elloing.!?!?!","e","ing",".!?!?!"]

ghci> [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
Just ["-3.141592653589793","-","3","141592653589793"]

ghci> tail `fmap` [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
Just ["-","3","141592653589793"]
ghci> return . tail =<< [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
Just ["-","3","141592653589793"]

ghci> maybe [] tail $ [$rx|^([+-])?([0-9]+)\.([0-9]+)|] (show $ negate pi)
["-","3","141592653589793"]

ghci> maybe [] tail $ [$rx|^([+-])?([0-9]+)\.([0-9]+)(.*)$|] (show (negate pi) ++ "asdx")
["-","3","141592653589793","asdx"]

----------------------------------------------------------------------------------------