#include <stdio.h>
#include <glib.h>

static const gchar *str = "[ds|fs]{|>{\\centering}p{0.11\\linewidth}|>{\\raggedright}p{0.05\\linewidth}|>{\\centering}p{0.07\\paperwidth}|>{\\centering}p{0.07\\paperwidth}|>{\\centering}m{0.07\\paperheight}|>{\\centering}m{0.07\\paperheight}|>{\\centering}p{0.07\\paperheight}|>{\\centering}p{0.07\\paperheight}|}";

static void
print_uppercase_words (const gchar *string)
{
  /* Print all uppercase-only words. */
  GRegex *regex;
  GMatchInfo *match_info;
  GError *error = NULL;
   
  regex = g_regex_new ("\\|>.*}\\|", 0, 0, NULL);
  g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
  while (g_match_info_matches (match_info))
    {
      gchar *word = g_match_info_fetch (match_info, 0);
      g_print ("Found: %s\n", word);
      g_free (word);
      g_match_info_next (match_info, &error);
    }
  g_match_info_free (match_info);
  g_regex_unref (regex);
  if (error != NULL)
    {
      g_printerr ("Error while matching: %s\n", error->message);
      g_error_free (error);
    }
}

int main (void)
{
/*  GRegex *regex;
  GMatchInfo *match_info;

  regex = g_regex_new ("s~^.*{\\|~~ ; s~\\|}.*$~~", 0, 0, NULL);
  g_regex_match (regex, string, 0, &match_info);

  whlie (g_match_info_matches (match_info))
    {
    }*/

  print_uppercase_words (str);

  return 0;
}

