diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c
index bba1e08..4962dda 100644
--- a/gst/subparse/gstsubparse.c
+++ b/gst/subparse/gstsubparse.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
-#include <regex.h>
+#include <glib.h>
 
 #include "gstsubparse.h"
 #include "gstssaparse.h"
@@ -979,36 +979,43 @@ static GstSubParseFormat
 gst_sub_parse_data_format_autodetect (gchar * match_str)
 {
   static gboolean need_init_regexps = TRUE;
-  static regex_t mdvd_rx;
-  static regex_t subrip_rx;
+  static GRegex *mdvd_grx;
+  static GRegex *subrip_grx;
   guint n1, n2, n3;
+  GError *gerr;
 
   /* initialize the regexps used the first time around */
   if (need_init_regexps) {
-    int err;
-    char errstr[128];
 
     need_init_regexps = FALSE;
-    if ((err = regcomp (&mdvd_rx, "^\\{[0-9]+\\}\\{[0-9]+\\}",
-                REG_EXTENDED | REG_NEWLINE | REG_NOSUB) != 0) ||
-        (err = regcomp (&subrip_rx, "^([ 0-9]){0,3}[0-9](\x0d)?\x0a"
-                "[ 0-9][0-9]:[ 0-9][0-9]:[ 0-9][0-9],[ 0-9]{2}[0-9]"
-                " --> ([ 0-9])?[0-9]:[ 0-9][0-9]:[ 0-9][0-9],[ 0-9]{2}[0-9]",
-                REG_EXTENDED | REG_NEWLINE | REG_NOSUB)) != 0) {
-      regerror (err, &subrip_rx, errstr, 127);
-      GST_WARNING ("Compilation of subrip regex failed: %s", errstr);
+    gerr = NULL;
+    mdvd_grx = g_regex_new ("^\\{[0-9]+\\}\\{[0-9]+\\}",
+                0,
+                0, &gerr);
+    if (mdvd_grx == NULL || gerr != NULL) {
+      GST_WARNING ("Compilation of mdvd regex failed: %s", gerr->message);
+      g_error_free (gerr);
+    }
+    gerr = NULL;
+    subrip_grx = g_regex_new ("^([ 0-9]){0,3}[0-9](\x0d)?\x0a"
+                  "[ 0-9][0-9]:[ 0-9][0-9]:[ 0-9][0-9],[ 0-9]{2}[0-9]"
+                  " --> ([ 0-9])?[0-9]:[ 0-9][0-9]:[ 0-9][0-9],[ 0-9]{2}[0-9]",
+                0,
+                0, &gerr);
+    if (subrip_grx == NULL || gerr != NULL) {
+      GST_WARNING ("Compilation of subrip regex failed: %s", gerr->message);
+      g_error_free (gerr);
     }
   }
 
-  if (regexec (&mdvd_rx, match_str, 0, NULL, 0) == 0) {
+  if (g_regex_match (mdvd_grx, match_str, 0, NULL) == TRUE) {
     GST_LOG ("MicroDVD (frame based) format detected");
     return GST_SUB_PARSE_FORMAT_MDVDSUB;
   }
-  if (regexec (&subrip_rx, match_str, 0, NULL, 0) == 0) {
+  if (g_regex_match (subrip_grx, match_str, 0, NULL) == TRUE) {
     GST_LOG ("SubRip (time based) format detected");
     return GST_SUB_PARSE_FORMAT_SUBRIP;
   }
-
   if (!strncmp (match_str, "FORMAT=TIME", 11)) {
     GST_LOG ("MPSub (time based) format detected");
     return GST_SUB_PARSE_FORMAT_MPSUB;
