mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-24 09:58:54 +02:00
113 lines
3.2 KiB
Plaintext
113 lines
3.2 KiB
Plaintext
<!-- ##### SECTION Title ##### -->
|
|
Glob-style pattern matching
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
|
|
|
Matches strings against patterns containing '*' and '?' wildcards.
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
|
<para>
|
|
The <function>g_pattern_match*</function> functions match a string
|
|
against a pattern containing '*' and '?' wildcards with similar semantics
|
|
as the standard <function>glob()</function> function: '*' matches an
|
|
arbitrary, possibly empty, string, '?' matches an arbitrary character.
|
|
</para>
|
|
<para>
|
|
Note that in contrast to <function>glob()</function>, the '/' character
|
|
<emphasis>can</emphasis> be matched by the wildcards, there are no
|
|
'[...]' character ranges and '*', '?' and '[' can <emphasis>not</emphasis>
|
|
be escaped to include them literally in a pattern.
|
|
</para>
|
|
<para>
|
|
The pattern matcher is restricted to ASCII and will not work correctly with
|
|
multibyte UTF-8 characters in the pattern or in the string to match.
|
|
</para>
|
|
<para>
|
|
When multiple string must be matched against the same pattern, it
|
|
is better to compile the pattern to a #GPatternSpec using
|
|
g_pattern_spec_new() and use g_pattern_match_string() instead of
|
|
g_pattern_match_simple(). This avoids the overhead of repeated
|
|
pattern compilation.
|
|
</para>
|
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
|
<para>
|
|
|
|
</para>
|
|
|
|
<!-- ##### ENUM GMatchType ##### -->
|
|
<para>
|
|
Enumeration representing different kinds of patterns. This is only used
|
|
internally for optimizing the match algorithm.
|
|
</para>
|
|
|
|
@G_MATCH_ALL: a general pattern.
|
|
@G_MATCH_ALL_TAIL: a general pattern which contains a fixed part matching
|
|
the end of the string.
|
|
@G_MATCH_HEAD: a pattern matching every string with a certain prefix.
|
|
@G_MATCH_TAIL: a pattern matching every string with a certain suffix.
|
|
@G_MATCH_EXACT: a pattern matching exactly one string.
|
|
@G_MATCH_LAST:
|
|
|
|
<!-- ##### STRUCT GPatternSpec ##### -->
|
|
<para>
|
|
A <structname>GPatternSpec</structname> is the 'compiled' form of a pattern.
|
|
There should be no need to access its fields.
|
|
</para>
|
|
|
|
@match_type: the #GMatchType of the pattern.
|
|
@pattern_length: the length of the pattern.
|
|
@pattern: the pattern. Note that this may be different from the @pattern
|
|
used to construct this <structname>GPatternSpec</structname>.
|
|
@pattern_reversed: the reverse of @pattern.
|
|
|
|
<!-- ##### FUNCTION g_pattern_spec_new ##### -->
|
|
<para>
|
|
Compiles a pattern to a #GPatternSpec.
|
|
</para>
|
|
|
|
@pattern: a string.
|
|
@Returns: a newly-allocated #GPatternSpec.
|
|
|
|
|
|
<!-- ##### FUNCTION g_pattern_spec_free ##### -->
|
|
<para>
|
|
Frees the memory allocated for the #GPatternSpec.
|
|
</para>
|
|
|
|
@pspec: a #GPatternSpec.
|
|
|
|
|
|
<!-- ##### FUNCTION g_pattern_match ##### -->
|
|
<para>
|
|
Matches a string against a compiled pattern.
|
|
</para>
|
|
|
|
@pspec: a #GPatternSpec.
|
|
@string_length: the length of @string.
|
|
@string: the string to match.
|
|
@string_reversed: the reverse of @string.
|
|
@Returns: %TRUE if @string matches @pspec.
|
|
|
|
|
|
<!-- ##### FUNCTION g_pattern_match_string ##### -->
|
|
<para>
|
|
Matches a string against a compiled pattern.
|
|
</para>
|
|
|
|
@pspec: a #GPatternSpec.
|
|
@string: the string to match.
|
|
@Returns: %TRUE if @string matches @pspec.
|
|
|
|
|
|
<!-- ##### FUNCTION g_pattern_match_simple ##### -->
|
|
<para>
|
|
Matches a string against a pattern.
|
|
</para>
|
|
|
|
@pattern: the pattern.
|
|
@string: the string to match.
|
|
@Returns: %TRUE if @string matches @pspec.
|
|
|
|
|