📄 glib-glob-style-pattern-matching.html
字号:
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>Whether the compiled patterns are equal.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3073506"></a><h3><a name="g-pattern-match"></a>g_pattern_match ()</h3><a class="indexterm" name="id3073516"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_pattern_match (<a href="glib-Glob-style-pattern-matching.html#GPatternSpec">GPatternSpec</a> *pspec, <a href="glib-Basic-Types.html#guint">guint</a> string_length, const <a href="glib-Basic-Types.html#gchar">gchar</a> *string, const <a href="glib-Basic-Types.html#gchar">gchar</a> *string_reversed);</pre><p>Matches a string against a compiled pattern. Passing the correct length of thestring given is mandatory. The reversed string can be omitted by passing <code class="literal">NULL</code>,this is more efficient if the reversed version of the string to be matched isnot at hand, as <a href="glib-Glob-style-pattern-matching.html#g-pattern-match"><code class="function">g_pattern_match()</code></a> will only construct it if the compiled patternrequires reverse matches.</p><p>Note that, if the user code will (possibly) match a string against a multitude of patterns containing wildcards, chances are high that some patterns will require a reversed string. In this case, it's more efficient to provide the reversed string to avoid multiple constructions thereof in the various calls to<a href="glib-Glob-style-pattern-matching.html#g-pattern-match"><code class="function">g_pattern_match()</code></a>.</p><p>Note also that the reverse of a UTF-8 encoded string can in general <span class="emphasis"><em>not</em></span> be obtained by <a href="glib-String-Utility-Functions.html#g-strreverse"><code class="function">g_strreverse()</code></a>.This works only if the string doesn't contain any multibyte characters.Glib offers the <code class="function">g_utf_strreverse()</code> function to reverse UTF-8 encoded strings.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>pspec</code></em> :</span></td><td>a <a href="glib-Glob-style-pattern-matching.html#GPatternSpec"><span class="type">GPatternSpec</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>string_length</code></em> :</span></td><td>the length of <em class="parameter"><code>string</code></em>.</td></tr><tr><td><span class="term"><em class="parameter"><code>string</code></em> :</span></td><td>the UTF-8 encoded string to match.</td></tr><tr><td><span class="term"><em class="parameter"><code>string_reversed</code></em> :</span></td><td>the reverse of <em class="parameter"><code>string</code></em> or <code class="literal">NULL</code>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><code class="literal">TRUE</code> if <em class="parameter"><code>string</code></em> matches <em class="parameter"><code>pspec</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3073891"></a><h3><a name="g-pattern-match-string"></a>g_pattern_match_string ()</h3><a class="indexterm" name="id3073902"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_pattern_match_string (<a href="glib-Glob-style-pattern-matching.html#GPatternSpec">GPatternSpec</a> *pspec, const <a href="glib-Basic-Types.html#gchar">gchar</a> *string);</pre><p>Matches a string against a compiled pattern. If the string is tobe matched against more than one pattern, consider using<a href="glib-Glob-style-pattern-matching.html#g-pattern-match"><code class="function">g_pattern_match()</code></a> instead while supplying the reversed string.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>pspec</code></em> :</span></td><td>a <a href="glib-Glob-style-pattern-matching.html#GPatternSpec"><span class="type">GPatternSpec</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>string</code></em> :</span></td><td>the UTF-8 encoded string to match.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><code class="literal">TRUE</code> if <em class="parameter"><code>string</code></em> matches <em class="parameter"><code>pspec</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3074019"></a><h3><a name="g-pattern-match-simple"></a>g_pattern_match_simple ()</h3><a class="indexterm" name="id3074030"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_pattern_match_simple (const <a href="glib-Basic-Types.html#gchar">gchar</a> *pattern, const <a href="glib-Basic-Types.html#gchar">gchar</a> *string);</pre><p>Matches a string against a pattern given as a string.If this function is to be called in a loop, it's more efficient to compilethe pattern once with <a href="glib-Glob-style-pattern-matching.html#g-pattern-spec-new"><code class="function">g_pattern_spec_new()</code></a> and call <a href="glib-Glob-style-pattern-matching.html#g-pattern-match-string"><code class="function">g_pattern_match_string()</code></a>repetively.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>pattern</code></em> :</span></td><td>the UTF-8 encoded pattern.</td></tr><tr><td><span class="term"><em class="parameter"><code>string</code></em> :</span></td><td>the UTF-8 encoded string to match.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><code class="literal">TRUE</code> if <em class="parameter"><code>string</code></em> matches <em class="parameter"><code>pspec</code></em>.</td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-Commandline-option-parser.html"><b><< Commandline option parser</b></a></td><td align="right"><a accesskey="n" href="glib-Simple-XML-Subset-Parser.html"><b>Simple XML Subset Parser >></b></a></td></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -