GRegex regular expression failing to match



I'm trying glib's GRegex functionality for the first time, and
apparently I am doing something wrong. I have some code like so:

code:
--------
  GError * error = NULL;

  GRegex * regex = g_regex_new ("^/(d+)$", 0, 0, &error);

  if (error != NULL)
    {
      // ...
    }

  GMatchInfo * match_info;

  g_regex_match (regex, path, 0, &match_info);

  if (g_match_info_matches (match_info))
    {
      gchar * word = g_match_info_fetch (match_info, 1);
      // ...
    }
--------

In my unit test, I pass in in the string "/1", hoping to match and then
pull out the number. A GError is not thrown (so my GRegex is compiling),
but g_match_info_matches() is returning FALSE.

Is there anything wrong with the regexp, or perhaps my g_regex_new()
options, or anything else obvious?

-- 
frigidcode.com
indicium.us



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]