1 /* GRegex -- regular expression API wrapper around PCRE.
3 * Copyright (C) 1999, 2000 Scott Wimer
4 * Copyright (C) 2004, Matthias Clasen <mclasen@redhat.com>
5 * Copyright (C) 2005 - 2006, Marco Barisione <marco@barisione.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <glib/gerror.h>
26 #include <glib/gstring.h>
32 G_REGEX_ERROR_COMPILE,
33 G_REGEX_ERROR_OPTIMIZE,
34 G_REGEX_ERROR_REPLACE,
38 #define G_REGEX_ERROR g_regex_error_quark ()
40 GQuark g_regex_error_quark (void);
42 /* Remember to update G_REGEX_COMPILE_MASK in gregex.c after
43 * adding a new flag. */
46 G_REGEX_CASELESS = 1 << 0,
47 G_REGEX_MULTILINE = 1 << 1,
48 G_REGEX_DOTALL = 1 << 2,
49 G_REGEX_EXTENDED = 1 << 3,
50 G_REGEX_ANCHORED = 1 << 4,
51 G_REGEX_DOLLAR_ENDONLY = 1 << 5,
52 G_REGEX_UNGREEDY = 1 << 9,
53 G_REGEX_RAW = 1 << 11,
54 G_REGEX_NO_AUTO_CAPTURE = 1 << 12,
55 G_REGEX_DUPNAMES = 1 << 19,
56 G_REGEX_NEWLINE_CR = 1 << 20,
57 G_REGEX_NEWLINE_LF = 1 << 21,
58 G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF
61 /* Remember to update G_REGEX_MATCH_MASK in gregex.c after
62 * adding a new flag. */
65 G_REGEX_MATCH_ANCHORED = 1 << 4,
66 G_REGEX_MATCH_NOTBOL = 1 << 7,
67 G_REGEX_MATCH_NOTEOL = 1 << 8,
68 G_REGEX_MATCH_NOTEMPTY = 1 << 10,
69 G_REGEX_MATCH_PARTIAL = 1 << 15,
70 G_REGEX_MATCH_NEWLINE_CR = 1 << 20,
71 G_REGEX_MATCH_NEWLINE_LF = 1 << 21,
72 G_REGEX_MATCH_NEWLINE_CRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF,
73 G_REGEX_MATCH_NEWLINE_ANY = 1 << 22,
76 typedef struct _GRegex GRegex;
78 typedef gboolean (*GRegexEvalCallback) (const GRegex*, const gchar*, GString*, gpointer);
81 GRegex *g_regex_new (const gchar *pattern,
82 GRegexCompileFlags compile_options,
83 GRegexMatchFlags match_options,
85 void g_regex_free (GRegex *regex);
86 gboolean g_regex_optimize (GRegex *regex,
88 GRegex *g_regex_copy (const GRegex *regex);
89 const gchar *g_regex_get_pattern (const GRegex *regex);
90 void g_regex_clear (GRegex *regex);
91 gboolean g_regex_match_simple (const gchar *pattern,
93 GRegexCompileFlags compile_options,
94 GRegexMatchFlags match_options);
95 gboolean g_regex_match (GRegex *regex,
97 GRegexMatchFlags match_options);
98 gboolean g_regex_match_full (GRegex *regex,
102 GRegexMatchFlags match_options,
104 gboolean g_regex_match_next (GRegex *regex,
106 GRegexMatchFlags match_options);
107 gboolean g_regex_match_next_full (GRegex *regex,
111 GRegexMatchFlags match_options,
113 gboolean g_regex_match_all (GRegex *regex,
115 GRegexMatchFlags match_options);
116 gboolean g_regex_match_all_full (GRegex *regex,
120 GRegexMatchFlags match_options,
122 gint g_regex_get_match_count (const GRegex *regex);
123 gboolean g_regex_is_partial_match (const GRegex *regex);
124 gchar *g_regex_fetch (const GRegex *regex,
126 const gchar *string);
127 gboolean g_regex_fetch_pos (const GRegex *regex,
131 gchar *g_regex_fetch_named (const GRegex *regex,
133 const gchar *string);
134 gboolean g_regex_fetch_named_pos (const GRegex *regex,
138 gchar **g_regex_fetch_all (const GRegex *regex,
139 const gchar *string);
140 gint g_regex_get_string_number (const GRegex *regex,
142 gchar **g_regex_split_simple (const gchar *pattern,
144 GRegexCompileFlags compile_options,
145 GRegexMatchFlags match_options);
146 gchar **g_regex_split (GRegex *regex,
148 GRegexMatchFlags match_options);
149 gchar **g_regex_split_full (GRegex *regex,
153 GRegexMatchFlags match_options,
156 gchar *g_regex_split_next (GRegex *regex,
158 GRegexMatchFlags match_options);
159 gchar *g_regex_split_next_full (GRegex *regex,
163 GRegexMatchFlags match_options,
165 gchar *g_regex_expand_references (GRegex *regex,
167 const gchar *string_to_expand,
169 gchar *g_regex_replace (GRegex *regex,
173 const gchar *replacement,
174 GRegexMatchFlags match_options,
176 gchar *g_regex_replace_literal (GRegex *regex,
180 const gchar *replacement,
181 GRegexMatchFlags match_options,
183 gchar *g_regex_replace_eval (GRegex *regex,
187 GRegexMatchFlags match_options,
188 GRegexEvalCallback eval,
191 gchar *g_regex_escape_string (const gchar *string,
198 #endif /* __G_REGEX_H__ */