]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE section PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" | |
3 | "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> | |
4 | ||
5 | <section id="bbv2.reference.modules.regex"> | |
6 | ||
7 | <title>regex</title> | |
8 | <indexterm> | |
9 | <primary>regex</primary> | |
10 | <secondary>module</secondary> | |
11 | </indexterm> | |
12 | ||
13 | <para> | |
14 | Contains rules for string processing using regular expressions. | |
15 | </para> | |
16 | ||
17 | <itemizedlist> | |
18 | ||
19 | <listitem><para> | |
20 | <code language="jam">"x*"</code> matches the pattern | |
21 | <code language="jam">"x"</code> zero or more times. | |
22 | </para></listitem> | |
23 | ||
24 | <listitem><para> | |
25 | <code language="jam">"x+"</code> matches <code language="jam">"x"</code> | |
26 | one or more times. | |
27 | </para></listitem> | |
28 | ||
29 | <listitem><para> | |
30 | <code language="jam">"x?"</code> matches <code language="jam">"x"</code> | |
31 | zero or one time. | |
32 | </para></listitem> | |
33 | ||
34 | <listitem><para> | |
35 | <code language="jam">"[abcd]"</code> matches any of the characters, | |
36 | <code language="jam">"a"</code>, <code language="jam">"b"</code>, | |
37 | <code language="jam">"c"</code>, and <code language="jam">"d"</code>. | |
38 | A character range such as <code language="jam">"[a-z]"</code> matches | |
39 | any character between <code language="jam">"a"</code> and | |
40 | <code language="jam">"z"</code>. <code language="jam">"[^abc]"</code> | |
41 | matches any character which is not <code language="jam">"a"</code>, | |
42 | <code language="jam">"b"</code>, or <code language="jam">"c"</code>. | |
43 | </para></listitem> | |
44 | ||
45 | <listitem><para> | |
46 | <code language="jam">"x|y"</code> matches either pattern | |
47 | <code language="jam">"x"</code> or pattern <code language="jam">"y"</code> | |
48 | </para></listitem> | |
49 | ||
50 | <listitem><para> | |
51 | <code language="jam">(x)</code> matches <code language="jam">"x"</code> | |
52 | and captures it. | |
53 | </para></listitem> | |
54 | ||
55 | <listitem><para> | |
56 | <code language="jam">"^"</code> matches the beginning of the string. | |
57 | </para></listitem> | |
58 | ||
59 | <listitem><para> | |
60 | <code language="jam">"$"</code> matches the end of the string. | |
61 | </para></listitem> | |
62 | ||
63 | <listitem><para> | |
64 | "\<" matches the beginning of a word. | |
65 | </para></listitem> | |
66 | ||
67 | <listitem><para> | |
68 | "\>" matches the end of a word. | |
69 | </para></listitem> | |
70 | ||
71 | </itemizedlist> | |
72 | ||
73 | <orderedlist> | |
74 | ||
75 | <listitem id="bbv2.reference.modules.regex.split"> | |
76 | <indexterm zone="bbv2.reference.modules.regex.split"> | |
77 | <primary>split</primary> | |
78 | <secondary>regex</secondary> | |
79 | </indexterm> | |
80 | <code language="jam">rule split ( string separator )</code> | |
81 | <para>Returns a list of the following substrings: | |
82 | <orderedlist> | |
83 | <listitem><para>from beginning till the first occurrence of | |
84 | <code language="jam">separator</code> or till the end, | |
85 | </para></listitem> | |
86 | <listitem><para>between each occurrence of | |
87 | <code language="jam">separator</code> and the next occurrence, | |
88 | </para></listitem> | |
89 | <listitem><para>from the last occurrence of | |
90 | <code language="jam">separator</code> till the end. | |
91 | </para></listitem> | |
92 | </orderedlist> | |
93 | If no separator is present, the result will contain only one element. | |
94 | </para> | |
95 | </listitem> | |
96 | ||
97 | <listitem id="bbv2.reference.modules.regex.split-list"> | |
98 | <indexterm zone="bbv2.reference.modules.regex.split-list"> | |
99 | <primary>split-list</primary> | |
100 | <secondary>regex</secondary> | |
101 | </indexterm> | |
102 | <code language="jam">rule split-list ( list * : separator )</code> | |
103 | <para>Returns the concatenated results of applying | |
104 | <link linkend="bbv2.reference.modules.regex.split">regex.split</link> | |
105 | to every element of the list using the separator pattern.</para> | |
106 | </listitem> | |
107 | ||
108 | <listitem id="bbv2.reference.modules.regex.match"> | |
109 | <indexterm zone="bbv2.reference.modules.regex.match"> | |
110 | <primary>match</primary> | |
111 | <secondary>regex</secondary> | |
112 | </indexterm> | |
113 | <code language="jam">rule match ( pattern : string : indices * )</code> | |
114 | <para>Match <code language="jam">string</code> against | |
115 | <code language="jam">pattern</code>, and return the elements | |
116 | indicated by <code language="jam">indices</code>. | |
117 | </para> | |
118 | </listitem> | |
119 | ||
120 | <listitem id="bbv2.reference.modules.regex.transform"> | |
121 | <indexterm zone="bbv2.reference.modules.regex.transform"> | |
122 | <primary>transform</primary> | |
123 | <secondary>regex</secondary> | |
124 | </indexterm> | |
125 | <code language="jam">rule transform ( list * : pattern : indices * )</code> | |
126 | <para>Matches all elements of <code language="jam">list</code> against | |
127 | the <code language="jam">pattern</code> and returns a list of elements | |
128 | indicated by <code language="jam">indices</code> of all successful | |
129 | matches. If <code language="jam">indices</code> is omitted returns a list | |
130 | of first parenthesized groups of all successful matches.</para> | |
131 | </listitem> | |
132 | ||
133 | <listitem id="bbv2.reference.modules.regex.escape"> | |
134 | <indexterm zone="bbv2.reference.modules.regex.escape"> | |
135 | <primary>escape</primary> | |
136 | <secondary>regex</secondary> | |
137 | </indexterm> | |
138 | <code language="jam">rule escape ( string : symbols : escape-symbol )</code> | |
139 | <para>Escapes all of the characters in <code language="jam">symbols</code> | |
140 | using the escape symbol <code language="jam">escape-symbol</code> for | |
141 | the given string, and returns the escaped string.</para> | |
142 | </listitem> | |
143 | ||
144 | <listitem id="bbv2.reference.modules.regex.replace"> | |
145 | <indexterm zone="bbv2.reference.modules.regex.replace"> | |
146 | <primary>replace</primary> | |
147 | <secondary>regex</secondary> | |
148 | </indexterm> | |
149 | <code language="jam">rule replace ( string match replacement )</code> | |
150 | <para>Replaces occurrences of a match string in a given string and | |
151 | returns the new string. The match string can be a regex expression.</para> | |
152 | </listitem> | |
153 | ||
154 | <listitem id="bbv2.reference.modules.regex.replace-list"> | |
155 | <indexterm zone="bbv2.reference.modules.regex.replace-list"> | |
156 | <primary>replace-list</primary> | |
157 | <secondary>regex</secondary> | |
158 | </indexterm> | |
159 | <code language="jam">rule replace-list ( list * : match : replacement )</code> | |
160 | <para>Replaces occurrences of a match string in a given list of strings | |
161 | and returns a list of new strings. The match string can be a regex | |
162 | expression. | |
163 | </para> | |
164 | </listitem> | |
165 | ||
166 | </orderedlist> | |
167 | ||
168 | <para>See also: <link linkend="jam.language.rules.builtins.utility._match__">MATCH</link></para> | |
169 | ||
170 | </section> |