123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title><GRegex>: </title>
- <meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
- <link rel="home" href="index.html" title="">
- <link rel="up" href="ch01.html" title="GLib">
- <link rel="prev" href="re50.html" title="<GPtrArray>">
- <link rel="next" href="re52.html" title="<%GLibRegexCompileFlags>">
- <meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
- <link rel="stylesheet" href="style.css" type="text/css">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
- <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
- <td width="100%" align="left" class="shortcuts"></td>
- <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
- <td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
- <td><a accesskey="p" href="re50.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
- <td><a accesskey="n" href="re52.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
- </tr></table>
- <div class="refentry">
- <a name="id-1.1.52"></a><div class="titlepage"></div>
- <div class="refnamediv">
- <h2><GRegex></h2>
- <p><GRegex></p>
- </div>
- <div class="refsect1">
- <a name="id-1.1.52.2"></a><h2>Description</h2>
- <p>The g_regex_*() functions implement regular
- expression pattern matching using syntax and semantics similar to
- Perl regular expression.
- </p>
- <p>Some functions accept a <em class="parameter"><code>start_position</code></em> argument, setting it differs
- from just passing over a shortened string and setting <span class="type">G_REGEX_MATCH_NOTBOL</span>
- in the case of a pattern that begins with any kind of lookbehind assertion.
- For example, consider the pattern "\Biss\B" which finds occurrences of "iss"
- in the middle of words. ("\B" matches only if the current position in the
- subject is not a word boundary.) When applied to the string "Mississipi"
- from the fourth byte, namely "issipi", it does not match, because "\B" is
- always false at the start of the subject, which is deemed to be a word
- boundary. However, if the entire string is passed , but with
- <em class="parameter"><code>start_position</code></em> set to 4, it finds the second occurrence of "iss" because
- it is able to look behind the starting point to discover that it is
- preceded by a letter.
- </p>
- <p>Note that, unless you set the <span class="type">G_REGEX_RAW</span> flag, all the strings passed
- to these functions must be encoded in UTF-8. The lengths and the positions
- inside the strings are in bytes and not in characters, so, for instance,
- "\xc3\xa0" (i.e. "à") is two bytes long but it is treated as a
- single character. If you set <span class="type">G_REGEX_RAW</span> the strings can be non-valid
- UTF-8 strings and a byte is treated as a character, so "\xc3\xa0" is two
- bytes and two characters long.
- </p>
- <p>When matching a pattern, "\n" matches only against a "\n" character in
- the string, and "\r" matches only a "\r" character. To match any newline
- sequence use "\R". This particular group matches either the two-character
- sequence CR + LF ("\r\n"), or one of the single characters LF (linefeed,
- U+000A, "\n"), VT vertical tab, U+000B, "\v"), FF (formfeed, U+000C, "\f"),
- CR (carriage return, U+000D, "\r"), NEL (next line, U+0085), LS (line
- separator, U+2028), or PS (paragraph separator, U+2029).
- </p>
- <p>The behaviour of the dot, circumflex, and dollar metacharacters are
- affected by newline characters, the default is to recognize any newline
- character (the same characters recognized by "\R"). This can be changed
- with <span class="type">G_REGEX_NEWLINE_CR</span>, <span class="type">G_REGEX_NEWLINE_LF</span> and <span class="type">G_REGEX_NEWLINE_CRLF</span>
- compile options, and with <span class="type">G_REGEX_MATCH_NEWLINE_ANY</span>,
- <span class="type">G_REGEX_MATCH_NEWLINE_CR</span>, <span class="type">G_REGEX_MATCH_NEWLINE_LF</span> and
- <span class="type">G_REGEX_MATCH_NEWLINE_CRLF</span> match options. These settings are also
- relevant when compiling a pattern if <span class="type">G_REGEX_EXTENDED</span> is set, and an
- unescaped "#" outside a character class is encountered. This indicates
- a comment that lasts until after the next newline.
- </p>
- <p>When setting the <code class="constant">G_REGEX_JAVASCRIPT_COMPAT</code> flag, pattern syntax and pattern
- matching is changed to be compatible with the way that regular expressions
- work in JavaScript. More precisely, a lonely ']' character in the pattern
- is a syntax error; the '\x' escape only allows 0 to 2 hexadecimal digits, and
- you must use the '\u' escape sequence with 4 hex digits to specify a unicode
- codepoint instead of '\x' or 'x{....}'. If '\x' or '\u' are not followed by
- the specified number of hex digits, they match 'x' and 'u' literally; also
- '\U' always matches 'U' instead of being an error in the pattern. Finally,
- pattern matching is modified so that back references to an unset subpattern
- group produces a match with the empty string instead of an error. See
- pcreapi(3) for more information.
- </p>
- <p>Creating and manipulating the same <span class="type">GRegex</span> structure from different
- threads is not a problem as <span class="type">GRegex</span> does not modify its internal
- state between creation and destruction, on the other hand <span class="type">GMatchInfo</span>
- is not threadsafe.
- </p>
- <p>The regular expressions low-level functionalities are obtained through
- the excellent
- [PCRE](http://www.pcre.org/)
- library written by Philip Hazel.</p>
- </div>
- <div class="refsect1">
- <a name="id-1.1.52.3"></a><h2>Functions</h2>
- <div class="refsect2">
- <a name="id-1.1.52.3.2"></a><h3>get-capture-count</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-capture-count self))
- </pre></div>
- <p>Returns the number of capturing subpatterns in the pattern.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.2.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.3"></a><h3>get-compile-flags</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-compile-flags self))
- </pre></div>
- <p>Returns the compile options that <em class="parameter"><code>regex</code></em> was created with.
- </p>
- <p>Depending on the version of PCRE that is used, this may or may not
- include flags set by option expressions such as <code class="code">(?i)</code> found at the
- top-level within the compiled pattern.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.3.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.4"></a><h3>get-has-cr-or-lf?</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-has-cr-or-lf? self))
- </pre></div>
- <p>Checks whether the pattern contains explicit CR or LF references.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.4.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.5"></a><h3>get-match-flags</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-match-flags self))
- </pre></div>
- <p>Returns the match options that <em class="parameter"><code>regex</code></em> was created with.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.5.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.6"></a><h3>get-max-backref</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-max-backref self))
- </pre></div>
- <p>Returns the number of the highest back reference
- in the pattern, or 0 if the pattern does not contain
- back references.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.6.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.7"></a><h3>get-max-lookbehind</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-max-lookbehind self))
- </pre></div>
- <p>Gets the number of characters in the longest lookbehind assertion in the
- pattern. This information is useful when doing multi-segment matching using
- the partial matching facilities.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.7.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.8"></a><h3>get-pattern</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-pattern self))
- </pre></div>
- <p>Gets the pattern string associated with <em class="parameter"><code>regex</code></em>, i.e. a copy of
- the string passed to <code class="function">g_regex_new()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.8.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.9"></a><h3>get-string-number</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:get-string-number self name))
- </pre></div>
- <p>Retrieves the number of the subexpression named <em class="parameter"><code>name</code></em>.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.9.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p><span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>name</p></td>
- <td class="parameter_description">
- <p>name of the subexpression</p>
- <p>Passed as <code class="code">name</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.10"></a><h3>match</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return match-info) (regex:match self string match-options))
- </pre></div>
- <p>Scans for a match in <em class="parameter"><code>string</code></em> for the pattern in <em class="parameter"><code>regex</code></em>.
- The <em class="parameter"><code>match_options</code></em> are combined with the match options specified
- when the <em class="parameter"><code>regex</code></em> structure was created, letting you have more
- flexibility in reusing <span class="type">GRegex</span> structures.
- </p>
- <p>Unless <code class="constant">G_REGEX_RAW</code> is specified in the options, <em class="parameter"><code>string</code></em> must be valid UTF-8.
- </p>
- <p>A <span class="type">GMatchInfo</span> structure, used to get information on the match,
- is stored in <em class="parameter"><code>match_info</code></em> if not <code class="constant">NULL</code>. Note that if <em class="parameter"><code>match_info</code></em>
- is not <code class="constant">NULL</code> then it is created even if the function returns <code class="constant">FALSE</code>,
- i.e. you must free it regardless if regular expression actually matched.
- </p>
- <p>To retrieve all the non-overlapping matches of the pattern in
- string you can use <code class="function">g_match_info_next()</code>.
- </p>
- <div class="informalexample"><pre class="programlisting">
- static void
- print_uppercase_words (const gchar *string)
- {
- // Print all uppercase-only words.
- GRegex *regex;
- GMatchInfo *match_info;
-
- regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
- g_regex_match (regex, string, 0, &match_info);
- while (g_match_info_matches (match_info))
- {
- gchar *word = g_match_info_fetch (match_info, 0);
- g_print ("Found: %s\n", word);
- g_free (word);
- g_match_info_next (match_info, NULL);
- }
- g_match_info_free (match_info);
- g_regex_unref (regex);
- }
- </pre></div>
- <p><em class="parameter"><code>string</code></em> is not copied and is used in <span class="type">GMatchInfo</span> internally. If
- you use any <span class="type">GMatchInfo</span> method (except <code class="function">g_match_info_free()</code>) after
- freeing or modifying <em class="parameter"><code>string</code></em> then the behaviour is undefined.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.10.9"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure from <code class="function">g_regex_new()</code></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to scan for matches</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match options</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_info</p></td>
- <td class="parameter_description">
- <p>pointer to location where to store
- the <span class="type">GMatchInfo</span>, or <code class="constant">NULL</code> if you do not need it</p>
- <p>Passed as <code class="code">match-info</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.11"></a><h3>match-all</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return match-info)
- (regex:match-all self string match-options))
- </pre></div>
- <p>Using the standard algorithm for regular expression matching only
- the longest match in the string is retrieved. This function uses
- a different algorithm so it can retrieve all the possible matches.
- For more documentation see <code class="function">g_regex_match_all_full()</code>.
- </p>
- <p>A <span class="type">GMatchInfo</span> structure, used to get information on the match, is
- stored in <em class="parameter"><code>match_info</code></em> if not <code class="constant">NULL</code>. Note that if <em class="parameter"><code>match_info</code></em> is
- not <code class="constant">NULL</code> then it is created even if the function returns <code class="constant">FALSE</code>,
- i.e. you must free it regardless if regular expression actually
- matched.
- </p>
- <p><em class="parameter"><code>string</code></em> is not copied and is used in <span class="type">GMatchInfo</span> internally. If
- you use any <span class="type">GMatchInfo</span> method (except <code class="function">g_match_info_free()</code>) after
- freeing or modifying <em class="parameter"><code>string</code></em> then the behaviour is undefined.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.11.6"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure from <code class="function">g_regex_new()</code></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to scan for matches</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match options</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_info</p></td>
- <td class="parameter_description">
- <p>pointer to location where to store
- the <span class="type">GMatchInfo</span>, or <code class="constant">NULL</code> if you do not need it</p>
- <p>Passed as <code class="code">match-info</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.12"></a><h3>match-all-full</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return match-info)
- (regex:match-all-full self string start-position match-options))
- </pre></div>
- <p>Using the standard algorithm for regular expression matching only
- the longest match in the <em class="parameter"><code>string</code></em> is retrieved, it is not possible
- to obtain all the available matches. For instance matching
- "<a> <b> <c>" against the pattern "<.*>"
- you get "<a> <b> <c>".
- </p>
- <p>This function uses a different algorithm (called DFA, i.e. deterministic
- finite automaton), so it can retrieve all the possible matches, all
- starting at the same point in the string. For instance matching
- "<a> <b> <c>" against the pattern "<.*>;"
- you would obtain three matches: "<a> <b> <c>",
- "<a> <b>" and "<a>".
- </p>
- <p>The number of matched strings is retrieved using
- <code class="function">g_match_info_get_match_count()</code>. To obtain the matched strings and
- their position you can use, respectively, <code class="function">g_match_info_fetch()</code> and
- <code class="function">g_match_info_fetch_pos()</code>. Note that the strings are returned in
- reverse order of length; that is, the longest matching string is
- given first.
- </p>
- <p>Note that the DFA algorithm is slower than the standard one and it
- is not able to capture substrings, so backreferences do not work.
- </p>
- <p>Setting <em class="parameter"><code>start_position</code></em> differs from just passing over a shortened
- string and setting <span class="type">G_REGEX_MATCH_NOTBOL</span> in the case of a pattern
- that begins with any kind of lookbehind assertion, such as "\b".
- </p>
- <p>Unless <code class="constant">G_REGEX_RAW</code> is specified in the options, <em class="parameter"><code>string</code></em> must be valid UTF-8.
- </p>
- <p>A <span class="type">GMatchInfo</span> structure, used to get information on the match, is
- stored in <em class="parameter"><code>match_info</code></em> if not <code class="constant">NULL</code>. Note that if <em class="parameter"><code>match_info</code></em> is
- not <code class="constant">NULL</code> then it is created even if the function returns <code class="constant">FALSE</code>,
- i.e. you must free it regardless if regular expression actually
- matched.
- </p>
- <p><em class="parameter"><code>string</code></em> is not copied and is used in <span class="type">GMatchInfo</span> internally. If
- you use any <span class="type">GMatchInfo</span> method (except <code class="function">g_match_info_free()</code>) after
- freeing or modifying <em class="parameter"><code>string</code></em> then the behaviour is undefined.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.12.11"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure from <code class="function">g_regex_new()</code></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to scan for matches</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string_len</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
- <p>Inferred from <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>start_position</p></td>
- <td class="parameter_description">
- <p>starting index of the string to match, in bytes</p>
- <p>Passed as <code class="code">start-position</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match options</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_info</p></td>
- <td class="parameter_description">
- <p>pointer to location where to store
- the <span class="type">GMatchInfo</span>, or <code class="constant">NULL</code> if you do not need it</p>
- <p>Passed as <code class="code">match-info</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.13"></a><h3>match-full</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return match-info)
- (regex:match-full self string start-position match-options))
- </pre></div>
- <p>Scans for a match in <em class="parameter"><code>string</code></em> for the pattern in <em class="parameter"><code>regex</code></em>.
- The <em class="parameter"><code>match_options</code></em> are combined with the match options specified
- when the <em class="parameter"><code>regex</code></em> structure was created, letting you have more
- flexibility in reusing <span class="type">GRegex</span> structures.
- </p>
- <p>Setting <em class="parameter"><code>start_position</code></em> differs from just passing over a shortened
- string and setting <span class="type">G_REGEX_MATCH_NOTBOL</span> in the case of a pattern
- that begins with any kind of lookbehind assertion, such as "\b".
- </p>
- <p>Unless <code class="constant">G_REGEX_RAW</code> is specified in the options, <em class="parameter"><code>string</code></em> must be valid UTF-8.
- </p>
- <p>A <span class="type">GMatchInfo</span> structure, used to get information on the match, is
- stored in <em class="parameter"><code>match_info</code></em> if not <code class="constant">NULL</code>. Note that if <em class="parameter"><code>match_info</code></em> is
- not <code class="constant">NULL</code> then it is created even if the function returns <code class="constant">FALSE</code>,
- i.e. you must free it regardless if regular expression actually
- matched.
- </p>
- <p><em class="parameter"><code>string</code></em> is not copied and is used in <span class="type">GMatchInfo</span> internally. If
- you use any <span class="type">GMatchInfo</span> method (except <code class="function">g_match_info_free()</code>) after
- freeing or modifying <em class="parameter"><code>string</code></em> then the behaviour is undefined.
- </p>
- <p>To retrieve all the non-overlapping matches of the pattern in
- string you can use <code class="function">g_match_info_next()</code>.
- </p>
- <div class="informalexample"><pre class="programlisting">
- static void
- print_uppercase_words (const gchar *string)
- {
- // Print all uppercase-only words.
- GRegex *regex;
- GMatchInfo *match_info;
- GError *error = NULL;
-
- regex = g_regex_new ("[A-Z]+", 0, 0, NULL);
- g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
- while (g_match_info_matches (match_info))
- {
- gchar *word = g_match_info_fetch (match_info, 0);
- g_print ("Found: %s\n", word);
- g_free (word);
- g_match_info_next (match_info, &error);
- }
- g_match_info_free (match_info);
- g_regex_unref (regex);
- if (error != NULL)
- {
- g_printerr ("Error while matching: %s\n", error->message);
- g_error_free (error);
- }
- }
- </pre></div>
- <div class="refsect3">
- <a name="id-1.1.52.3.13.10"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure from <code class="function">g_regex_new()</code></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to scan for matches</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string_len</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
- <p>Inferred from <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>start_position</p></td>
- <td class="parameter_description">
- <p>starting index of the string to match, in bytes</p>
- <p>Passed as <code class="code">start-position</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match options</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_info</p></td>
- <td class="parameter_description">
- <p>pointer to location where to store
- the <span class="type">GMatchInfo</span>, or <code class="constant">NULL</code> if you do not need it</p>
- <p>Passed as <code class="code">match-info</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.14"></a><h3>ref</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:ref self))
- </pre></div>
- <p>Increases reference count of <em class="parameter"><code>regex</code></em> by 1.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.14.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.15"></a><h3>replace</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return)
- (regex:replace self string start-position replacement match-options))
- </pre></div>
- <p>Replaces all occurrences of the pattern in <em class="parameter"><code>regex</code></em> with the
- replacement text. Backreferences of the form '\number' or
- '\g<number>' in the replacement text are interpolated by the
- number-th captured subexpression of the match, '\g<name>' refers
- to the captured subexpression with the given name. '\0' refers
- to the complete match, but '\0' followed by a number is the octal
- representation of a character. To include a literal '\' in the
- replacement, write '\\\\'.
- </p>
- <p>There are also escapes that changes the case of the following text:
- </p>
- <p>- \l: Convert to lower case the next character
- - \u: Convert to upper case the next character
- - \L: Convert to lower case till \E
- - \U: Convert to upper case till \E
- - \E: End case modification
- </p>
- <p>If you do not need to use backreferences use <code class="function">g_regex_replace_literal()</code>.
- </p>
- <p>The <em class="parameter"><code>replacement</code></em> string must be UTF-8 encoded even if <span class="type">G_REGEX_RAW</span> was
- passed to <code class="function">g_regex_new()</code>. If you want to use not UTF-8 encoded strings
- you can use <code class="function">g_regex_replace_literal()</code>.
- </p>
- <p>Setting <em class="parameter"><code>start_position</code></em> differs from just passing over a shortened
- string and setting <span class="type">G_REGEX_MATCH_NOTBOL</span> in the case of a pattern that
- begins with any kind of lookbehind assertion, such as "\b".</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.15.9"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to perform matches against</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string_len</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
- <p>Inferred from <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>start_position</p></td>
- <td class="parameter_description">
- <p>starting index of the string to match, in bytes</p>
- <p>Passed as <code class="code">start-position</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>replacement</p></td>
- <td class="parameter_description">
- <p>text to replace each match with</p>
- <p>Passed as <code class="code">replacement</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>options for the match</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.16"></a><h3>replace-literal</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return)
- (regex:replace-literal self string start-position replacement match-options))
- </pre></div>
- <p>Replaces all occurrences of the pattern in <em class="parameter"><code>regex</code></em> with the
- replacement text. <em class="parameter"><code>replacement</code></em> is replaced literally, to
- include backreferences use <code class="function">g_regex_replace()</code>.
- </p>
- <p>Setting <em class="parameter"><code>start_position</code></em> differs from just passing over a
- shortened string and setting <span class="type">G_REGEX_MATCH_NOTBOL</span> in the
- case of a pattern that begins with any kind of lookbehind
- assertion, such as "\b".</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.16.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to perform matches against</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string_len</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
- <p>Inferred from <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>start_position</p></td>
- <td class="parameter_description">
- <p>starting index of the string to match, in bytes</p>
- <p>Passed as <code class="code">start-position</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>replacement</p></td>
- <td class="parameter_description">
- <p>text to replace each match with</p>
- <p>Passed as <code class="code">replacement</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>options for the match</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.17"></a><h3>split</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:split self string match-options))
- </pre></div>
- <p>Breaks the string on the pattern, and returns an array of the tokens.
- If the pattern contains capturing parentheses, then the text for each
- of the substrings will also be returned. If the pattern does not match
- anywhere in the string, then the whole string is returned as the first
- token.
- </p>
- <p>As a special case, the result of splitting the empty string "" is an
- empty vector, not a vector containing a single string. The reason for
- this special case is that being able to represent an empty vector is
- typically more useful than consistent handling of empty elements. If
- you do need to represent empty elements, you'll need to check for the
- empty string before calling this function.
- </p>
- <p>A pattern that can match empty strings splits <em class="parameter"><code>string</code></em> into separate
- characters wherever it matches the empty string between characters.
- For example splitting "ab c" using as a separator "\s*", you will get
- "a", "b" and "c".</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.17.6"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to split with the pattern</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match time option flags</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.18"></a><h3>split-full</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return)
- (regex:split-full self string start-position match-options max-tokens))
- </pre></div>
- <p>Breaks the string on the pattern, and returns an array of the tokens.
- If the pattern contains capturing parentheses, then the text for each
- of the substrings will also be returned. If the pattern does not match
- anywhere in the string, then the whole string is returned as the first
- token.
- </p>
- <p>As a special case, the result of splitting the empty string "" is an
- empty vector, not a vector containing a single string. The reason for
- this special case is that being able to represent an empty vector is
- typically more useful than consistent handling of empty elements. If
- you do need to represent empty elements, you'll need to check for the
- empty string before calling this function.
- </p>
- <p>A pattern that can match empty strings splits <em class="parameter"><code>string</code></em> into separate
- characters wherever it matches the empty string between characters.
- For example splitting "ab c" using as a separator "\s*", you will get
- "a", "b" and "c".
- </p>
- <p>Setting <em class="parameter"><code>start_position</code></em> differs from just passing over a shortened
- string and setting <span class="type">G_REGEX_MATCH_NOTBOL</span> in the case of a pattern
- that begins with any kind of lookbehind assertion, such as "\b".</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.18.7"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span> structure</p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to split with the pattern</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string_len</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
- <p>Inferred from <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>start_position</p></td>
- <td class="parameter_description">
- <p>starting index of the string to match, in bytes</p>
- <p>Passed as <code class="code">start-position</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match time option flags</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>max_tokens</p></td>
- <td class="parameter_description">
- <p>the maximum number of tokens to split <em class="parameter"><code>string</code></em> into.
- If this is less than 1, the string is split completely</p>
- <p>Passed as <code class="code">max-tokens</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.19"></a><h3>unref</h3>
- <div class="informalexample"><pre class="programlisting">(define-values () (regex:unref self))
- </pre></div>
- <p>Decreases reference count of <em class="parameter"><code>regex</code></em> by 1. When reference count drops
- to zero, it frees all the memory associated with the regex structure.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.19.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table><tr>
- <td class="parameter_name"><p>regex</p></td>
- <td class="parameter_description">
- <p>a <span class="type">GRegex</span></p>
- <p>Passed as <code class="code">self</code></p>
- </td>
- </tr></table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.20"></a><h3>regex:new</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:new pattern compile-options match-options))
- </pre></div>
- <p>Undocumented</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.20.4"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>pattern</p></td>
- <td class="parameter_description">
- <p></p>
- <p>Passed as <code class="code">pattern</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>compile_options</p></td>
- <td class="parameter_description">
- <p></p>
- <p>Passed as <code class="code">compile-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p></p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.21"></a><h3>regex:check-replacement</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return has-references) (regex:check-replacement replacement))
- </pre></div>
- <p>Checks whether <em class="parameter"><code>replacement</code></em> is a valid replacement string
- (see <code class="function">g_regex_replace()</code>), i.e. that all escape sequences in
- it are valid.
- </p>
- <p>If <em class="parameter"><code>has_references</code></em> is not <code class="constant">NULL</code> then <em class="parameter"><code>replacement</code></em> is checked
- for pattern references. For instance, replacement text 'foo\n'
- does not contain references and may be evaluated without information
- about actual match, but '\0\1' (whole match followed by first
- subpattern) requires valid <span class="type">GMatchInfo</span> object.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.21.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>replacement</p></td>
- <td class="parameter_description">
- <p>the replacement string</p>
- <p>Passed as <code class="code">replacement</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>has_references</p></td>
- <td class="parameter_description">
- <p>location to store information about
- references in <em class="parameter"><code>replacement</code></em> or <code class="constant">NULL</code></p>
- <p>Passed as <code class="code">has-references</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.22"></a><h3>regex:error-quark</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:error-quark))
- </pre></div>
- <p>Undocumented</p>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.23"></a><h3>regex:escape-nul</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:escape-nul string length))
- </pre></div>
- <p>Escapes the nul characters in <em class="parameter"><code>string</code></em> to "\x00". It can be used
- to compile a regex with embedded nul characters.
- </p>
- <p>For completeness, <em class="parameter"><code>length</code></em> can be -1 for a nul-terminated string.
- In this case the output string will be of course equal to <em class="parameter"><code>string</code></em>.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.23.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to escape</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>length</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em></p>
- <p>Passed as <code class="code">length</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.24"></a><h3>regex:escape-string</h3>
- <div class="informalexample"><pre class="programlisting">(define-values (%return) (regex:escape-string string))
- </pre></div>
- <p>Escapes the special characters used for regular expressions
- in <em class="parameter"><code>string</code></em>, for instance "a.b*c" becomes "a\.b\*c". This
- function is useful to dynamically generate regular expressions.
- </p>
- <p><em class="parameter"><code>string</code></em> can contain nul characters that are replaced with "\0",
- in this case remember to specify the correct length of <em class="parameter"><code>string</code></em>
- in <em class="parameter"><code>length</code></em>.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.24.5"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to escape</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>length</p></td>
- <td class="parameter_description">
- <p>the length of <em class="parameter"><code>string</code></em>, in bytes, or -1 if <em class="parameter"><code>string</code></em> is nul-terminated</p>
- <p>Inferred from <code class="code">string</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.25"></a><h3>regex:match-simple?</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return)
- (regex:match-simple? pattern string compile-options match-options))
- </pre></div>
- <p>Scans for a match in <em class="parameter"><code>string</code></em> for <em class="parameter"><code>pattern</code></em>.
- </p>
- <p>This function is equivalent to <code class="function">g_regex_match()</code> but it does not
- require to compile the pattern with <code class="function">g_regex_new()</code>, avoiding some
- lines of code when you need just to do a match without extracting
- substrings, capture counts, and so on.
- </p>
- <p>If this function is to be called on the same <em class="parameter"><code>pattern</code></em> more than
- once, it's more efficient to compile the pattern once with
- <code class="function">g_regex_new()</code> and then use <code class="function">g_regex_match()</code>.</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.25.6"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>pattern</p></td>
- <td class="parameter_description">
- <p>the regular expression</p>
- <p>Passed as <code class="code">pattern</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to scan for matches</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>compile_options</p></td>
- <td class="parameter_description">
- <p>compile options for the regular expression, or 0</p>
- <p>Passed as <code class="code">compile-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match options, or 0</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- <div class="refsect2">
- <a name="id-1.1.52.3.26"></a><h3>regex:split-simple</h3>
- <div class="informalexample"><pre class="programlisting">(define-values
- (%return)
- (regex:split-simple pattern string compile-options match-options))
- </pre></div>
- <p>Breaks the string on the pattern, and returns an array of
- the tokens. If the pattern contains capturing parentheses,
- then the text for each of the substrings will also be returned.
- If the pattern does not match anywhere in the string, then the
- whole string is returned as the first token.
- </p>
- <p>This function is equivalent to <code class="function">g_regex_split()</code> but it does
- not require to compile the pattern with <code class="function">g_regex_new()</code>, avoiding
- some lines of code when you need just to do a split without
- extracting substrings, capture counts, and so on.
- </p>
- <p>If this function is to be called on the same <em class="parameter"><code>pattern</code></em> more than
- once, it's more efficient to compile the pattern once with
- <code class="function">g_regex_new()</code> and then use <code class="function">g_regex_split()</code>.
- </p>
- <p>As a special case, the result of splitting the empty string ""
- is an empty vector, not a vector containing a single string.
- The reason for this special case is that being able to represent
- an empty vector is typically more useful than consistent handling
- of empty elements. If you do need to represent empty elements,
- you'll need to check for the empty string before calling this
- function.
- </p>
- <p>A pattern that can match empty strings splits <em class="parameter"><code>string</code></em> into
- separate characters wherever it matches the empty string between
- characters. For example splitting "ab c" using as a separator
- "\s*", you will get "a", "b" and "c".</p>
- <div class="refsect3">
- <a name="id-1.1.52.3.26.8"></a><h4>Parameters</h4>
- <div class="informaltable"><table>
- <tr>
- <td class="parameter_name"><p>pattern</p></td>
- <td class="parameter_description">
- <p>the regular expression</p>
- <p>Passed as <code class="code">pattern</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>string</p></td>
- <td class="parameter_description">
- <p>the string to scan for matches</p>
- <p>Passed as <code class="code">string</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>compile_options</p></td>
- <td class="parameter_description">
- <p>compile options for the regular expression, or 0</p>
- <p>Passed as <code class="code">compile-options</code></p>
- </td>
- </tr>
- <tr>
- <td class="parameter_name"><p>match_options</p></td>
- <td class="parameter_description">
- <p>match options, or 0</p>
- <p>Passed as <code class="code">match-options</code></p>
- </td>
- </tr>
- </table></div>
- </div>
- </div>
- </div>
- </div>
- <div class="footer">
- <hr>Generated by GTK-Doc V1.33.1</div>
- </body>
- </html>
|