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 GMatchInfo *match_info,
85 GRegex *g_regex_new (const gchar *pattern,
86 GRegexCompileFlags compile_options,
87 GRegexMatchFlags match_options,
89 GRegex *g_regex_ref (GRegex *regex);
90 void g_regex_unref (GRegex *regex);
91 const gchar *g_regex_get_pattern (const GRegex *regex);
92 gint g_regex_get_max_backref (const GRegex *regex);
93 gint g_regex_get_capture_count (const GRegex *regex);
94 gint g_regex_get_string_number (const GRegex *regex,
96 gchar *g_regex_escape_string (const gchar *string,
100 gboolean g_regex_match_simple (const gchar *pattern,
102 GRegexCompileFlags compile_options,
103 GRegexMatchFlags match_options);
104 gboolean g_regex_match (const GRegex *regex,
106 GRegexMatchFlags match_options,
107 GMatchInfo **match_info);
108 gboolean g_regex_match_full (const GRegex *regex,
112 GRegexMatchFlags match_options,
113 GMatchInfo **match_info,
115 gboolean g_regex_match_all (const GRegex *regex,
117 GRegexMatchFlags match_options,
118 GMatchInfo **match_info);
119 gboolean g_regex_match_all_full (const GRegex *regex,
123 GRegexMatchFlags match_options,
124 GMatchInfo **match_info,
127 /* String splitting. */
128 gchar **g_regex_split_simple (const gchar *pattern,
130 GRegexCompileFlags compile_options,
131 GRegexMatchFlags match_options);
132 gchar **g_regex_split (const GRegex *regex,
134 GRegexMatchFlags match_options);
135 gchar **g_regex_split_full (const GRegex *regex,
139 GRegexMatchFlags match_options,
143 /* String replacement. */
144 gchar *g_regex_replace (const GRegex *regex,
148 const gchar *replacement,
149 GRegexMatchFlags match_options,
151 gchar *g_regex_replace_literal (const GRegex *regex,
155 const gchar *replacement,
156 GRegexMatchFlags match_options,
158 gchar *g_regex_replace_eval (const GRegex *regex,
162 GRegexMatchFlags match_options,
163 GRegexEvalCallback eval,
166 gboolean g_regex_check_replacement (const gchar *replacement,
167 gboolean *has_references,
171 GRegex *g_match_info_get_regex (const GMatchInfo *match_info);
172 const gchar *g_match_info_get_string (const GMatchInfo *match_info);
174 void g_match_info_free (GMatchInfo *match_info);
175 gboolean g_match_info_next (GMatchInfo *match_info,
177 gboolean g_match_info_matches (const GMatchInfo *match_info);
178 gint g_match_info_get_match_count (const GMatchInfo *match_info);
179 gboolean g_match_info_is_partial_match (const GMatchInfo *match_info);
180 gchar *g_match_info_expand_references(const GMatchInfo *match_info,
181 const gchar *string_to_expand,
183 gchar *g_match_info_fetch (const GMatchInfo *match_info,
185 gboolean g_match_info_fetch_pos (const GMatchInfo *match_info,
189 gchar *g_match_info_fetch_named (const GMatchInfo *match_info,
191 gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info,
195 gchar **g_match_info_fetch_all (const GMatchInfo *match_info);
200 #endif /* __G_REGEX_H__ */