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 - 2007, 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_OPTIMIZE = 1 << 13,
56 G_REGEX_DUPNAMES = 1 << 19,
57 G_REGEX_NEWLINE_CR = 1 << 20,
58 G_REGEX_NEWLINE_LF = 1 << 21,
59 G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF
62 /* Remember to update G_REGEX_MATCH_MASK in gregex.c after
63 * adding a new flag. */
66 G_REGEX_MATCH_ANCHORED = 1 << 4,
67 G_REGEX_MATCH_NOTBOL = 1 << 7,
68 G_REGEX_MATCH_NOTEOL = 1 << 8,
69 G_REGEX_MATCH_NOTEMPTY = 1 << 10,
70 G_REGEX_MATCH_PARTIAL = 1 << 15,
71 G_REGEX_MATCH_NEWLINE_CR = 1 << 20,
72 G_REGEX_MATCH_NEWLINE_LF = 1 << 21,
73 G_REGEX_MATCH_NEWLINE_CRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF,
74 G_REGEX_MATCH_NEWLINE_ANY = 1 << 22
77 typedef struct _GRegex GRegex;
78 typedef struct _GMatchInfo GMatchInfo;
80 typedef gboolean (*GRegexEvalCallback) (const GRegex *,
87 GRegex *g_regex_new (const gchar *pattern,
88 GRegexCompileFlags compile_options,
89 GRegexMatchFlags match_options,
91 void g_regex_free (GRegex *regex);
92 const gchar *g_regex_get_pattern (const GRegex *regex);
93 gint g_regex_get_max_backref (const GRegex *regex);
94 gint g_regex_get_capture_count (const GRegex *regex);
95 gint g_regex_get_string_number (const GRegex *regex,
97 gchar *g_regex_escape_string (const gchar *string,
101 gboolean g_regex_match_simple (const gchar *pattern,
103 GRegexCompileFlags compile_options,
104 GRegexMatchFlags match_options);
105 gboolean g_regex_match (const GRegex *regex,
107 GRegexMatchFlags match_options,
108 GMatchInfo **match_info);
109 gboolean g_regex_match_full (const GRegex *regex,
113 GRegexMatchFlags match_options,
114 GMatchInfo **match_info,
116 gboolean g_regex_match_all (const GRegex *regex,
118 GRegexMatchFlags match_options,
119 GMatchInfo **match_info);
120 gboolean g_regex_match_all_full (const GRegex *regex,
124 GRegexMatchFlags match_options,
125 GMatchInfo **match_info,
128 /* String splitting. */
129 gchar **g_regex_split_simple (const gchar *pattern,
131 GRegexCompileFlags compile_options,
132 GRegexMatchFlags match_options);
133 gchar **g_regex_split (const GRegex *regex,
135 GRegexMatchFlags match_options);
136 gchar **g_regex_split_full (const GRegex *regex,
140 GRegexMatchFlags match_options,
144 /* String replacement. */
145 gchar *g_regex_replace (const GRegex *regex,
149 const gchar *replacement,
150 GRegexMatchFlags match_options,
152 gchar *g_regex_replace_literal (const GRegex *regex,
156 const gchar *replacement,
157 GRegexMatchFlags match_options,
159 gchar *g_regex_replace_eval (const GRegex *regex,
163 GRegexMatchFlags match_options,
164 GRegexEvalCallback eval,
169 void g_match_info_free (GMatchInfo *match_info);
170 gboolean g_match_info_next (GMatchInfo *match_info,
172 gboolean g_match_info_matches (const GMatchInfo *match_info);
173 gint g_match_info_get_match_count (const GMatchInfo *match_info);
174 gboolean g_match_info_is_partial_match (const GMatchInfo *match_info);
175 gchar *g_match_info_expand_references(const GMatchInfo *match_info,
176 const gchar *string_to_expand,
178 gchar *g_match_info_fetch (const GMatchInfo *match_info,
180 gboolean g_match_info_fetch_pos (const GMatchInfo *match_info,
184 gchar *g_match_info_fetch_named (const GMatchInfo *match_info,
186 gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info,
190 gchar **g_match_info_fetch_all (const GMatchInfo *match_info);
195 #endif /* __G_REGEX_H__ */