1 <!-- ##### SECTION Title ##### -->
2 Glob-style pattern matching
4 <!-- ##### SECTION Short_Description ##### -->
6 Matches strings against patterns containing '*' and '?' wildcards.
8 <!-- ##### SECTION Long_Description ##### -->
10 The <function>g_pattern_match*</function> functions match a string
11 against a pattern containing '*' and '?' wildcards with similar semantics
12 as the standard <function>glob()</function> function: '*' matches an
13 arbitrary, possibly empty, string, '?' matches an arbitrary character.
14 Note that in contrast to <function>glob()</function>, the '/' character
15 <emphasis>can</emphasis> be matched by the wildcards.
18 There is no way to include literal '*' or '?' characters in a pattern.
21 When multiple string must be matched against the same pattern, it
22 is better to compile the pattern to a #GPatternSpec using
23 g_pattern_spec_new() and use g_pattern_match_string() instead of
24 g_pattern_match_simple(). This avoids the overhead of repeated
27 <!-- ##### SECTION See_Also ##### -->
32 <!-- ##### ENUM GMatchType ##### -->
34 Enumeration representing different kinds of patterns. This is only used
35 internally for optimizing the match algorithm.
38 @G_MATCH_ALL: a general pattern.
39 @G_MATCH_ALL_TAIL: a general pattern which contains a fixed part matching
40 the end of the string.
41 @G_MATCH_HEAD: a pattern matching every string with a certain prefix.
42 @G_MATCH_TAIL: a pattern matching every string with a certain suffix.
43 @G_MATCH_EXACT: a pattern matching exactly one string.
46 <!-- ##### STRUCT GPatternSpec ##### -->
48 A <structname>GPatternSpec</structname> is the 'compiled' form of a pattern.
49 There should be no need to access its fields.
52 @match_type: the #GMatchType of the pattern.
53 @pattern_length: the length of the pattern.
54 @pattern: the pattern. Note that this may be different from the @pattern
55 used to construct this <structname>GPatternSpec</structname>.
56 @pattern_reversed: the reverse of @pattern.
58 <!-- ##### FUNCTION g_pattern_spec_new ##### -->
60 Compiles a pattern to a #GPatternSpec.
64 @Returns: a newly-allocated #GPatternSpec.
67 <!-- ##### FUNCTION g_pattern_spec_free ##### -->
69 Frees the memory allocated for the #GPatternSpec.
72 @pspec: a #GPatternSpec.
75 <!-- ##### FUNCTION g_pattern_match ##### -->
77 Matches a string against a compiled pattern.
80 @pspec: a #GPatternSpec.
81 @string_length: the length of @string.
82 @string: the string to match.
83 @string_reversed: the reverse of @string.
84 @Returns: %TRUE if @string matches @pspec.
87 <!-- ##### FUNCTION g_pattern_match_string ##### -->
89 Matches a string against a compiled pattern.
92 @pspec: a #GPatternSpec.
93 @string: the string to match.
94 @Returns: %TRUE if @string matches @pspec.
97 <!-- ##### FUNCTION g_pattern_match_simple ##### -->
99 Matches a string against a pattern.
102 @pattern: the pattern.
103 @string: the string to match.
104 @Returns: %TRUE if @string matches @pspec.