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">
5 <section id=
"bbv2.reference.modules.regex">
9 <primary>regex
</primary>
10 <secondary>module
</secondary>
14 Contains rules for string processing using regular expressions.
20 <code language=
"jam">"x*"</code> matches the pattern
21 <code language=
"jam">"x"</code> zero or more times.
25 <code language=
"jam">"x+"</code> matches
<code language=
"jam">"x"</code>
30 <code language=
"jam">"x?"</code> matches
<code language=
"jam">"x"</code>
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>.
46 <code language=
"jam">"x|y"</code> matches either pattern
47 <code language=
"jam">"x"</code> or pattern
<code language=
"jam">"y"</code>
51 <code language=
"jam">(x)
</code> matches
<code language=
"jam">"x"</code>
56 <code language=
"jam">"^"</code> matches the beginning of the string.
60 <code language=
"jam">"$"</code> matches the end of the string.
64 "\<" matches the beginning of a word.
68 "\>" matches the end of a word.
75 <listitem id=
"bbv2.reference.modules.regex.split">
76 <indexterm zone=
"bbv2.reference.modules.regex.split">
77 <primary>split
</primary>
78 <secondary>regex
</secondary>
80 <code language=
"jam">rule split ( string separator )
</code>
81 <para>Returns a list of the following substrings:
83 <listitem><para>from beginning till the first occurrence of
84 <code language=
"jam">separator
</code> or till the end,
86 <listitem><para>between each occurrence of
87 <code language=
"jam">separator
</code> and the next occurrence,
89 <listitem><para>from the last occurrence of
90 <code language=
"jam">separator
</code> till the end.
93 If no separator is present, the result will contain only one element.
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>
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>
108 <listitem id=
"bbv2.reference.modules.regex.match">
109 <indexterm zone=
"bbv2.reference.modules.regex.match">
110 <primary>match
</primary>
111 <secondary>regex
</secondary>
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>.
120 <listitem id=
"bbv2.reference.modules.regex.transform">
121 <indexterm zone=
"bbv2.reference.modules.regex.transform">
122 <primary>transform
</primary>
123 <secondary>regex
</secondary>
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>
133 <listitem id=
"bbv2.reference.modules.regex.escape">
134 <indexterm zone=
"bbv2.reference.modules.regex.escape">
135 <primary>escape
</primary>
136 <secondary>regex
</secondary>
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>
144 <listitem id=
"bbv2.reference.modules.regex.replace">
145 <indexterm zone=
"bbv2.reference.modules.regex.replace">
146 <primary>replace
</primary>
147 <secondary>regex
</secondary>
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>
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>
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
168 <para>See also:
<link linkend=
"jam.language.rules.builtins.utility._match__">MATCH
</link></para>