match_simple


Description:

[ CCode ( cname = "g_pattern_match_simple" ) ]
public static bool match_simple (string pattern, string str)

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 compile the pattern once with PatternSpec and call g_pattern_match_string repeatedly.

Example: Match a string against a pattern:

public static int main (string[] args) {
// Output: ``true``
bool res = PatternSpec.match_simple ("dilbert-????/??/??.*", "dilbert-1999/39/01.png");
print ("%s\n", res.to_string ());

// Output: ``true``
res = PatternSpec.match_simple ("dilbert-????/??/??.*", "dilbert-1999/39/01.jpg");
print ("%s\n", res.to_string ());

// Output: ``false``
res = PatternSpec.match_simple ("dilbert-????/??/??.*", "dilbert-1999X/39/01.jpg");
print ("%s\n", res.to_string ());

return 0;
}

valac --pkg glib-2.0 GLib.PatternSpec.match_simple.vala

Parameters:

pattern

the UTF-8 encoded pattern

string

the UTF-8 encoded string to match

Returns:

true if string matches pspec