aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/text/regex.lux
blob: 8de3d70e7da3439e87cbccd2adb8d63e312b1fad (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]]]
 [\\library
  ["[0]" /]])

(def .public documentation
  (List $.Documentation)
  (list ($.module /._
                  "")

        ($.definition /.incorrect_quantification)

        ($.definition /.regex
          "Create lexers using regular-expression syntax."
          ["Literals"
           (regex "a")]
          ["Wildcards"
           (regex ".")]
          ["Escaping"
           (regex "\.")]
          ["Character classes"
           (regex "\d")
           (regex "\p{Lower}")
           (regex "[abc]")
           (regex "[a-z]")
           (regex "[a-zA-Z]")
           (regex "[a-z&&[def]]")]
          ["Negation"
           (regex "[^abc]")
           (regex "[^a-z]")
           (regex "[^a-zA-Z]")
           (regex "[a-z&&[^bc]]")
           (regex "[a-z&&[^m-p]]")]
          ["Combinations"
           (regex "aa")
           (regex "a?")
           (regex "a*")
           (regex "a+")]
          ["Specific amounts"
           (regex "a{2}")]
          ["At least"
           (regex "a{1,}")]
          ["At most"
           (regex "a{,1}")]
          ["Between"
           (regex "a{1,2}")]
          ["Groups"
           (regex "a(.)c")
           (regex "a(b+)c")
           (regex "(\d{3})-(\d{3})-(\d{4})")
           (regex "(\d{3})-(?:\d{3})-(\d{4})")
           (regex "(?<code>\d{3})-\k<code>-(\d{4})")
           (regex "(?<code>\d{3})-\k<code>-(\d{4})-\0")
           (regex "(\d{3})-((\d{3})-(\d{4}))")]
          ["Alternation"
           (regex "a|b")
           (regex "a(.)(.)|b(.)(.)")])

        ($.definition /.pattern
          "Allows you to test text against regular expressions."
          [(when some_text
             (pattern "(\d{3})-(\d{3})-(\d{4})"
                      [_ country_code area_code place_code])
             do_some_thing_when_number

             (pattern "\w+")
             do_some_thing_when_word

             _
             do_something_else)])
        ))