|
|
|||
File indexing completed on 2026-05-06 08:41:18
0001 /* GRegex -- regular expression API wrapper around PCRE. 0002 * 0003 * Copyright (C) 1999, 2000 Scott Wimer 0004 * Copyright (C) 2004, Matthias Clasen <mclasen@redhat.com> 0005 * Copyright (C) 2005 - 2007, Marco Barisione <marco@barisione.org> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.1-or-later 0008 * 0009 * This library is free software; you can redistribute it and/or 0010 * modify it under the terms of the GNU Lesser General Public 0011 * License as published by the Free Software Foundation; either 0012 * version 2.1 of the License, or (at your option) any later version. 0013 * 0014 * This library is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 * Lesser General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Lesser General Public License 0020 * along with this library; if not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef __G_REGEX_H__ 0024 #define __G_REGEX_H__ 0025 0026 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) 0027 #error "Only <glib.h> can be included directly." 0028 #endif 0029 0030 #include <glib/gerror.h> 0031 #include <glib/gstring.h> 0032 0033 G_BEGIN_DECLS 0034 0035 /** 0036 * GRegexError: 0037 * @G_REGEX_ERROR_COMPILE: Compilation of the regular expression failed. 0038 * @G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed. 0039 * @G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement 0040 * string. 0041 * @G_REGEX_ERROR_MATCH: The match process failed. 0042 * @G_REGEX_ERROR_INTERNAL: Internal error of the regular expression engine. 0043 * Since 2.16 0044 * @G_REGEX_ERROR_STRAY_BACKSLASH: "\\" at end of pattern. Since 2.16 0045 * @G_REGEX_ERROR_MISSING_CONTROL_CHAR: "\\c" at end of pattern. Since 2.16 0046 * @G_REGEX_ERROR_UNRECOGNIZED_ESCAPE: Unrecognized character follows "\\". 0047 * Since 2.16 0048 * @G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER: Numbers out of order in "{}" 0049 * quantifier. Since 2.16 0050 * @G_REGEX_ERROR_QUANTIFIER_TOO_BIG: Number too big in "{}" quantifier. 0051 * Since 2.16 0052 * @G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS: Missing terminating "]" for 0053 * character class. Since 2.16 0054 * @G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS: Invalid escape sequence 0055 * in character class. Since 2.16 0056 * @G_REGEX_ERROR_RANGE_OUT_OF_ORDER: Range out of order in character class. 0057 * Since 2.16 0058 * @G_REGEX_ERROR_NOTHING_TO_REPEAT: Nothing to repeat. Since 2.16 0059 * @G_REGEX_ERROR_UNRECOGNIZED_CHARACTER: Unrecognized character after "(?", 0060 * "(?<" or "(?P". Since 2.16 0061 * @G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS: POSIX named classes are 0062 * supported only within a class. Since 2.16 0063 * @G_REGEX_ERROR_UNMATCHED_PARENTHESIS: Missing terminating ")" or ")" 0064 * without opening "(". Since 2.16 0065 * @G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE: Reference to non-existent 0066 * subpattern. Since 2.16 0067 * @G_REGEX_ERROR_UNTERMINATED_COMMENT: Missing terminating ")" after comment. 0068 * Since 2.16 0069 * @G_REGEX_ERROR_EXPRESSION_TOO_LARGE: Regular expression too large. 0070 * Since 2.16 0071 * @G_REGEX_ERROR_MEMORY_ERROR: Failed to get memory. Since 2.16 0072 * @G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND: Lookbehind assertion is not 0073 * fixed length. Since 2.16 0074 * @G_REGEX_ERROR_MALFORMED_CONDITION: Malformed number or name after "(?(". 0075 * Since 2.16 0076 * @G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES: Conditional group contains 0077 * more than two branches. Since 2.16 0078 * @G_REGEX_ERROR_ASSERTION_EXPECTED: Assertion expected after "(?(". 0079 * Since 2.16 0080 * @G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME: Unknown POSIX class name. 0081 * Since 2.16 0082 * @G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED: POSIX collating 0083 * elements are not supported. Since 2.16 0084 * @G_REGEX_ERROR_HEX_CODE_TOO_LARGE: Character value in "\\x{...}" sequence 0085 * is too large. Since 2.16 0086 * @G_REGEX_ERROR_INVALID_CONDITION: Invalid condition "(?(0)". Since 2.16 0087 * @G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND: \\C not allowed in 0088 * lookbehind assertion. Since 2.16 0089 * @G_REGEX_ERROR_INFINITE_LOOP: Recursive call could loop indefinitely. 0090 * Since 2.16 0091 * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR: Missing terminator 0092 * in subpattern name. Since 2.16 0093 * @G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME: Two named subpatterns have 0094 * the same name. Since 2.16 0095 * @G_REGEX_ERROR_MALFORMED_PROPERTY: Malformed "\\P" or "\\p" sequence. 0096 * Since 2.16 0097 * @G_REGEX_ERROR_UNKNOWN_PROPERTY: Unknown property name after "\\P" or 0098 * "\\p". Since 2.16 0099 * @G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG: Subpattern name is too long 0100 * (maximum 32 characters). Since 2.16 0101 * @G_REGEX_ERROR_TOO_MANY_SUBPATTERNS: Too many named subpatterns (maximum 0102 * 10,000). Since 2.16 0103 * @G_REGEX_ERROR_INVALID_OCTAL_VALUE: Octal value is greater than "\\377". 0104 * Since 2.16 0105 * @G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE: "DEFINE" group contains more 0106 * than one branch. Since 2.16 0107 * @G_REGEX_ERROR_DEFINE_REPETION: Repeating a "DEFINE" group is not allowed. 0108 * This error is never raised. Since: 2.16 Deprecated: 2.34 0109 * @G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS: Inconsistent newline options. 0110 * Since 2.16 0111 * @G_REGEX_ERROR_MISSING_BACK_REFERENCE: "\\g" is not followed by a braced, 0112 * angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16 0113 * @G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE: relative reference must not be zero. Since: 2.34 0114 * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN: the backtracing 0115 * control verb used does not allow an argument. Since: 2.34 0116 * @G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB: unknown backtracing 0117 * control verb. Since: 2.34 0118 * @G_REGEX_ERROR_NUMBER_TOO_BIG: number is too big in escape sequence. Since: 2.34 0119 * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME: Missing subpattern name. Since: 2.34 0120 * @G_REGEX_ERROR_MISSING_DIGIT: Missing digit. Since 2.34 0121 * @G_REGEX_ERROR_INVALID_DATA_CHARACTER: In JavaScript compatibility mode, 0122 * "[" is an invalid data character. Since: 2.34 0123 * @G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME: different names for subpatterns of the 0124 * same number are not allowed. Since: 2.34 0125 * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED: the backtracing control 0126 * verb requires an argument. Since: 2.34 0127 * @G_REGEX_ERROR_INVALID_CONTROL_CHAR: "\\c" must be followed by an ASCII 0128 * character. Since: 2.34 0129 * @G_REGEX_ERROR_MISSING_NAME: "\\k" is not followed by a braced, angle-bracketed, or 0130 * quoted name. Since: 2.34 0131 * @G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS: "\\N" is not supported in a class. Since: 2.34 0132 * @G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES: too many forward references. Since: 2.34 0133 * @G_REGEX_ERROR_NAME_TOO_LONG: the name is too long in "(*MARK)", "(*PRUNE)", 0134 * "(*SKIP)", or "(*THEN)". Since: 2.34 0135 * @G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE: the character value in the \\u sequence is 0136 * too large. Since: 2.34 0137 * 0138 * Error codes returned by regular expressions functions. 0139 * 0140 * Since: 2.14 0141 */ 0142 typedef enum 0143 { 0144 G_REGEX_ERROR_COMPILE, 0145 G_REGEX_ERROR_OPTIMIZE, 0146 G_REGEX_ERROR_REPLACE, 0147 G_REGEX_ERROR_MATCH, 0148 G_REGEX_ERROR_INTERNAL, 0149 0150 /* These are the error codes from PCRE + 100 */ 0151 G_REGEX_ERROR_STRAY_BACKSLASH = 101, 0152 G_REGEX_ERROR_MISSING_CONTROL_CHAR = 102, 0153 G_REGEX_ERROR_UNRECOGNIZED_ESCAPE = 103, 0154 G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER = 104, 0155 G_REGEX_ERROR_QUANTIFIER_TOO_BIG = 105, 0156 G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS = 106, 0157 G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS = 107, 0158 G_REGEX_ERROR_RANGE_OUT_OF_ORDER = 108, 0159 G_REGEX_ERROR_NOTHING_TO_REPEAT = 109, 0160 G_REGEX_ERROR_UNRECOGNIZED_CHARACTER = 112, 0161 G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113, 0162 G_REGEX_ERROR_UNMATCHED_PARENTHESIS = 114, 0163 G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE = 115, 0164 G_REGEX_ERROR_UNTERMINATED_COMMENT = 118, 0165 G_REGEX_ERROR_EXPRESSION_TOO_LARGE = 120, 0166 G_REGEX_ERROR_MEMORY_ERROR = 121, 0167 G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND = 125, 0168 G_REGEX_ERROR_MALFORMED_CONDITION = 126, 0169 G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES = 127, 0170 G_REGEX_ERROR_ASSERTION_EXPECTED = 128, 0171 G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME = 130, 0172 G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131, 0173 G_REGEX_ERROR_HEX_CODE_TOO_LARGE = 134, 0174 G_REGEX_ERROR_INVALID_CONDITION = 135, 0175 G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136, 0176 G_REGEX_ERROR_INFINITE_LOOP = 140, 0177 G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR = 142, 0178 G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME = 143, 0179 G_REGEX_ERROR_MALFORMED_PROPERTY = 146, 0180 G_REGEX_ERROR_UNKNOWN_PROPERTY = 147, 0181 G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG = 148, 0182 G_REGEX_ERROR_TOO_MANY_SUBPATTERNS = 149, 0183 G_REGEX_ERROR_INVALID_OCTAL_VALUE = 151, 0184 G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE = 154, 0185 G_REGEX_ERROR_DEFINE_REPETION = 155, 0186 G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS = 156, 0187 G_REGEX_ERROR_MISSING_BACK_REFERENCE = 157, 0188 G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE = 158, 0189 G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN = 159, 0190 G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB = 160, 0191 G_REGEX_ERROR_NUMBER_TOO_BIG = 161, 0192 G_REGEX_ERROR_MISSING_SUBPATTERN_NAME = 162, 0193 G_REGEX_ERROR_MISSING_DIGIT = 163, 0194 G_REGEX_ERROR_INVALID_DATA_CHARACTER = 164, 0195 G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME = 165, 0196 G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED = 166, 0197 G_REGEX_ERROR_INVALID_CONTROL_CHAR = 168, 0198 G_REGEX_ERROR_MISSING_NAME = 169, 0199 G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS = 171, 0200 G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES = 172, 0201 G_REGEX_ERROR_NAME_TOO_LONG = 175, 0202 G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE = 176 0203 } GRegexError; 0204 0205 /** 0206 * G_REGEX_ERROR: 0207 * 0208 * Error domain for regular expressions. Errors in this domain will be 0209 * from the #GRegexError enumeration. See #GError for information on 0210 * error domains. 0211 * 0212 * Since: 2.14 0213 */ 0214 #define G_REGEX_ERROR g_regex_error_quark () 0215 0216 GLIB_AVAILABLE_IN_ALL 0217 GQuark g_regex_error_quark (void); 0218 0219 /** 0220 * GRegexCompileFlags: 0221 * @G_REGEX_DEFAULT: No special options set. Since: 2.74 0222 * @G_REGEX_CASELESS: Letters in the pattern match both upper- and 0223 * lowercase letters. This option can be changed within a pattern 0224 * by a "(?i)" option setting. 0225 * @G_REGEX_MULTILINE: By default, GRegex treats the strings as consisting 0226 * of a single line of characters (even if it actually contains 0227 * newlines). The "start of line" metacharacter ("^") matches only 0228 * at the start of the string, while the "end of line" metacharacter 0229 * ("$") matches only at the end of the string, or before a terminating 0230 * newline (unless %G_REGEX_DOLLAR_ENDONLY is set). When 0231 * %G_REGEX_MULTILINE is set, the "start of line" and "end of line" 0232 * constructs match immediately following or immediately before any 0233 * newline in the string, respectively, as well as at the very start 0234 * and end. This can be changed within a pattern by a "(?m)" option 0235 * setting. 0236 * @G_REGEX_DOTALL: A dot metacharacter (".") in the pattern matches all 0237 * characters, including newlines. Without it, newlines are excluded. 0238 * This option can be changed within a pattern by a ("?s") option setting. 0239 * @G_REGEX_EXTENDED: Whitespace data characters in the pattern are 0240 * totally ignored except when escaped or inside a character class. 0241 * Whitespace does not include the VT character (code 11). In addition, 0242 * characters between an unescaped "#" outside a character class and 0243 * the next newline character, inclusive, are also ignored. This can 0244 * be changed within a pattern by a "(?x)" option setting. 0245 * @G_REGEX_ANCHORED: The pattern is forced to be "anchored", that is, 0246 * it is constrained to match only at the first matching point in the 0247 * string that is being searched. This effect can also be achieved by 0248 * appropriate constructs in the pattern itself such as the "^" 0249 * metacharacter. 0250 * @G_REGEX_DOLLAR_ENDONLY: A dollar metacharacter ("$") in the pattern 0251 * matches only at the end of the string. Without this option, a 0252 * dollar also matches immediately before the final character if 0253 * it is a newline (but not before any other newlines). This option 0254 * is ignored if %G_REGEX_MULTILINE is set. 0255 * @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that 0256 * they are not greedy by default, but become greedy if followed by "?". 0257 * It can also be set by a "(?U)" option setting within the pattern. 0258 * @G_REGEX_RAW: Usually strings must be valid UTF-8 strings, using this 0259 * flag they are considered as a raw sequence of bytes. 0260 * @G_REGEX_NO_AUTO_CAPTURE: Disables the use of numbered capturing 0261 * parentheses in the pattern. Any opening parenthesis that is not 0262 * followed by "?" behaves as if it were followed by "?:" but named 0263 * parentheses can still be used for capturing (and they acquire numbers 0264 * in the usual way). 0265 * @G_REGEX_OPTIMIZE: Since 2.74 and the port to pcre2, requests JIT 0266 * compilation, which, if the just-in-time compiler is available, further 0267 * processes a compiled pattern into machine code that executes much 0268 * faster. However, it comes at the cost of extra processing before the 0269 * match is performed, so it is most beneficial to use this when the same 0270 * compiled pattern is used for matching many times. Before 2.74 this 0271 * option used the built-in non-JIT optimizations in pcre1. 0272 * @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the 0273 * first newline. Since: 2.34 0274 * @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not 0275 * be unique. This can be helpful for certain types of pattern when it 0276 * is known that only one instance of the named subpattern can ever be 0277 * matched. 0278 * @G_REGEX_NEWLINE_CR: Usually any newline character or character sequence is 0279 * recognized. If this option is set, the only recognized newline character 0280 * is '\r'. 0281 * @G_REGEX_NEWLINE_LF: Usually any newline character or character sequence is 0282 * recognized. If this option is set, the only recognized newline character 0283 * is '\n'. 0284 * @G_REGEX_NEWLINE_CRLF: Usually any newline character or character sequence is 0285 * recognized. If this option is set, the only recognized newline character 0286 * sequence is '\r\n'. 0287 * @G_REGEX_NEWLINE_ANYCRLF: Usually any newline character or character sequence 0288 * is recognized. If this option is set, the only recognized newline character 0289 * sequences are '\r', '\n', and '\r\n'. Since: 2.34 0290 * @G_REGEX_BSR_ANYCRLF: Usually any newline character or character sequence 0291 * is recognised. If this option is set, then "\R" only recognizes the newline 0292 * characters '\r', '\n' and '\r\n'. Since: 2.34 0293 * @G_REGEX_JAVASCRIPT_COMPAT: Changes behaviour so that it is compatible with 0294 * JavaScript rather than PCRE. Since GLib 2.74 this is no longer supported, 0295 * as libpcre2 does not support it. Since: 2.34 Deprecated: 2.74 0296 * 0297 * Flags specifying compile-time options. 0298 * 0299 * Since: 2.14 0300 */ 0301 /* Remember to update G_REGEX_COMPILE_MASK in gregex.c after 0302 * adding a new flag. 0303 */ 0304 typedef enum 0305 { 0306 G_REGEX_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, 0307 G_REGEX_CASELESS = 1 << 0, 0308 G_REGEX_MULTILINE = 1 << 1, 0309 G_REGEX_DOTALL = 1 << 2, 0310 G_REGEX_EXTENDED = 1 << 3, 0311 G_REGEX_ANCHORED = 1 << 4, 0312 G_REGEX_DOLLAR_ENDONLY = 1 << 5, 0313 G_REGEX_UNGREEDY = 1 << 9, 0314 G_REGEX_RAW = 1 << 11, 0315 G_REGEX_NO_AUTO_CAPTURE = 1 << 12, 0316 G_REGEX_OPTIMIZE = 1 << 13, 0317 G_REGEX_FIRSTLINE = 1 << 18, 0318 G_REGEX_DUPNAMES = 1 << 19, 0319 G_REGEX_NEWLINE_CR = 1 << 20, 0320 G_REGEX_NEWLINE_LF = 1 << 21, 0321 G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF, 0322 G_REGEX_NEWLINE_ANYCRLF = G_REGEX_NEWLINE_CR | 1 << 22, 0323 G_REGEX_BSR_ANYCRLF = 1 << 23, 0324 G_REGEX_JAVASCRIPT_COMPAT GLIB_DEPRECATED_ENUMERATOR_IN_2_74 = 1 << 25 0325 } GRegexCompileFlags; 0326 0327 /** 0328 * GRegexMatchFlags: 0329 * @G_REGEX_MATCH_DEFAULT: No special options set. Since: 2.74 0330 * @G_REGEX_MATCH_ANCHORED: The pattern is forced to be "anchored", that is, 0331 * it is constrained to match only at the first matching point in the 0332 * string that is being searched. This effect can also be achieved by 0333 * appropriate constructs in the pattern itself such as the "^" 0334 * metacharacter. 0335 * @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is 0336 * not the beginning of a line, so the circumflex metacharacter should 0337 * not match before it. Setting this without %G_REGEX_MULTILINE (at 0338 * compile time) causes circumflex never to match. This option affects 0339 * only the behaviour of the circumflex metacharacter, it does not 0340 * affect "\A". 0341 * @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is 0342 * not the end of a line, so the dollar metacharacter should not match 0343 * it nor (except in multiline mode) a newline immediately before it. 0344 * Setting this without %G_REGEX_MULTILINE (at compile time) causes 0345 * dollar never to match. This option affects only the behaviour of 0346 * the dollar metacharacter, it does not affect "\Z" or "\z". 0347 * @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid 0348 * match if this option is set. If there are alternatives in the pattern, 0349 * they are tried. If all the alternatives match the empty string, the 0350 * entire match fails. For example, if the pattern "a?b?" is applied to 0351 * a string not beginning with "a" or "b", it matches the empty string 0352 * at the start of the string. With this flag set, this match is not 0353 * valid, so GRegex searches further into the string for occurrences 0354 * of "a" or "b". 0355 * @G_REGEX_MATCH_PARTIAL: Turns on the partial matching feature, for more 0356 * documentation on partial matching see g_match_info_is_partial_match(). 0357 * @G_REGEX_MATCH_NEWLINE_CR: Overrides the newline definition set when 0358 * creating a new #GRegex, setting the '\r' character as line terminator. 0359 * @G_REGEX_MATCH_NEWLINE_LF: Overrides the newline definition set when 0360 * creating a new #GRegex, setting the '\n' character as line terminator. 0361 * @G_REGEX_MATCH_NEWLINE_CRLF: Overrides the newline definition set when 0362 * creating a new #GRegex, setting the '\r\n' characters sequence as line terminator. 0363 * @G_REGEX_MATCH_NEWLINE_ANY: Overrides the newline definition set when 0364 * creating a new #GRegex, any Unicode newline sequence 0365 * is recognised as a newline. These are '\r', '\n' and '\rn', and the 0366 * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), 0367 * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and 0368 * U+2029 PARAGRAPH SEPARATOR. 0369 * @G_REGEX_MATCH_NEWLINE_ANYCRLF: Overrides the newline definition set when 0370 * creating a new #GRegex; any '\r', '\n', or '\r\n' character sequence 0371 * is recognized as a newline. Since: 2.34 0372 * @G_REGEX_MATCH_BSR_ANYCRLF: Overrides the newline definition for "\R" set when 0373 * creating a new #GRegex; only '\r', '\n', or '\r\n' character sequences 0374 * are recognized as a newline by "\R". Since: 2.34 0375 * @G_REGEX_MATCH_BSR_ANY: Overrides the newline definition for "\R" set when 0376 * creating a new #GRegex; any Unicode newline character or character sequence 0377 * are recognized as a newline by "\R". These are '\r', '\n' and '\rn', and the 0378 * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), 0379 * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and 0380 * U+2029 PARAGRAPH SEPARATOR. Since: 2.34 0381 * @G_REGEX_MATCH_PARTIAL_SOFT: An alias for %G_REGEX_MATCH_PARTIAL. Since: 2.34 0382 * @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to 0383 * to %G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match 0384 * is found, without continuing to search for a possible complete match. See 0385 * g_match_info_is_partial_match() for more information. Since: 2.34 0386 * @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like %G_REGEX_MATCH_NOTEMPTY, but only applied to 0387 * the start of the matched string. For anchored 0388 * patterns this can only happen for pattern containing "\K". Since: 2.34 0389 * 0390 * Flags specifying match-time options. 0391 * 0392 * Since: 2.14 0393 */ 0394 /* Remember to update G_REGEX_MATCH_MASK in gregex.c after 0395 * adding a new flag. */ 0396 typedef enum 0397 { 0398 G_REGEX_MATCH_DEFAULT GLIB_AVAILABLE_ENUMERATOR_IN_2_74 = 0, 0399 G_REGEX_MATCH_ANCHORED = 1 << 4, 0400 G_REGEX_MATCH_NOTBOL = 1 << 7, 0401 G_REGEX_MATCH_NOTEOL = 1 << 8, 0402 G_REGEX_MATCH_NOTEMPTY = 1 << 10, 0403 G_REGEX_MATCH_PARTIAL = 1 << 15, 0404 G_REGEX_MATCH_NEWLINE_CR = 1 << 20, 0405 G_REGEX_MATCH_NEWLINE_LF = 1 << 21, 0406 G_REGEX_MATCH_NEWLINE_CRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF, 0407 G_REGEX_MATCH_NEWLINE_ANY = 1 << 22, 0408 G_REGEX_MATCH_NEWLINE_ANYCRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_ANY, 0409 G_REGEX_MATCH_BSR_ANYCRLF = 1 << 23, 0410 G_REGEX_MATCH_BSR_ANY = 1 << 24, 0411 G_REGEX_MATCH_PARTIAL_SOFT = G_REGEX_MATCH_PARTIAL, 0412 G_REGEX_MATCH_PARTIAL_HARD = 1 << 27, 0413 G_REGEX_MATCH_NOTEMPTY_ATSTART = 1 << 28 0414 } GRegexMatchFlags; 0415 0416 typedef struct _GRegex GRegex; 0417 0418 0419 /** 0420 * GMatchInfo: 0421 * 0422 * A GMatchInfo is an opaque struct used to return information about 0423 * matches. 0424 */ 0425 typedef struct _GMatchInfo GMatchInfo; 0426 0427 /** 0428 * GRegexEvalCallback: 0429 * @match_info: the #GMatchInfo generated by the match. 0430 * Use g_match_info_get_regex() and g_match_info_get_string() if you 0431 * need the #GRegex or the matched string. 0432 * @result: a #GString containing the new string 0433 * @user_data: user data passed to g_regex_replace_eval() 0434 * 0435 * Specifies the type of the function passed to g_regex_replace_eval(). 0436 * It is called for each occurrence of the pattern in the string passed 0437 * to g_regex_replace_eval(), and it should append the replacement to 0438 * @result. 0439 * 0440 * Returns: %FALSE to continue the replacement process, %TRUE to stop it 0441 * 0442 * Since: 2.14 0443 */ 0444 typedef gboolean (*GRegexEvalCallback) (const GMatchInfo *match_info, 0445 GString *result, 0446 gpointer user_data); 0447 0448 0449 GLIB_AVAILABLE_IN_ALL 0450 GRegex *g_regex_new (const gchar *pattern, 0451 GRegexCompileFlags compile_options, 0452 GRegexMatchFlags match_options, 0453 GError **error); 0454 GLIB_AVAILABLE_IN_ALL 0455 GRegex *g_regex_ref (GRegex *regex); 0456 GLIB_AVAILABLE_IN_ALL 0457 void g_regex_unref (GRegex *regex); 0458 GLIB_AVAILABLE_IN_ALL 0459 const gchar *g_regex_get_pattern (const GRegex *regex); 0460 GLIB_AVAILABLE_IN_ALL 0461 gint g_regex_get_max_backref (const GRegex *regex); 0462 GLIB_AVAILABLE_IN_ALL 0463 gint g_regex_get_capture_count (const GRegex *regex); 0464 GLIB_AVAILABLE_IN_ALL 0465 gboolean g_regex_get_has_cr_or_lf (const GRegex *regex); 0466 GLIB_AVAILABLE_IN_2_38 0467 gint g_regex_get_max_lookbehind (const GRegex *regex); 0468 GLIB_AVAILABLE_IN_ALL 0469 gint g_regex_get_string_number (const GRegex *regex, 0470 const gchar *name); 0471 GLIB_AVAILABLE_IN_ALL 0472 gchar *g_regex_escape_string (const gchar *string, 0473 gint length); 0474 GLIB_AVAILABLE_IN_ALL 0475 gchar *g_regex_escape_nul (const gchar *string, 0476 gint length); 0477 0478 GLIB_AVAILABLE_IN_ALL 0479 GRegexCompileFlags g_regex_get_compile_flags (const GRegex *regex); 0480 GLIB_AVAILABLE_IN_ALL 0481 GRegexMatchFlags g_regex_get_match_flags (const GRegex *regex); 0482 0483 /* Matching. */ 0484 GLIB_AVAILABLE_IN_ALL 0485 gboolean g_regex_match_simple (const gchar *pattern, 0486 const gchar *string, 0487 GRegexCompileFlags compile_options, 0488 GRegexMatchFlags match_options); 0489 GLIB_AVAILABLE_IN_ALL 0490 gboolean g_regex_match (const GRegex *regex, 0491 const gchar *string, 0492 GRegexMatchFlags match_options, 0493 GMatchInfo **match_info); 0494 GLIB_AVAILABLE_IN_ALL 0495 gboolean g_regex_match_full (const GRegex *regex, 0496 const gchar *string, 0497 gssize string_len, 0498 gint start_position, 0499 GRegexMatchFlags match_options, 0500 GMatchInfo **match_info, 0501 GError **error); 0502 GLIB_AVAILABLE_IN_ALL 0503 gboolean g_regex_match_all (const GRegex *regex, 0504 const gchar *string, 0505 GRegexMatchFlags match_options, 0506 GMatchInfo **match_info); 0507 GLIB_AVAILABLE_IN_ALL 0508 gboolean g_regex_match_all_full (const GRegex *regex, 0509 const gchar *string, 0510 gssize string_len, 0511 gint start_position, 0512 GRegexMatchFlags match_options, 0513 GMatchInfo **match_info, 0514 GError **error); 0515 0516 /* String splitting. */ 0517 GLIB_AVAILABLE_IN_ALL 0518 gchar **g_regex_split_simple (const gchar *pattern, 0519 const gchar *string, 0520 GRegexCompileFlags compile_options, 0521 GRegexMatchFlags match_options); 0522 GLIB_AVAILABLE_IN_ALL 0523 gchar **g_regex_split (const GRegex *regex, 0524 const gchar *string, 0525 GRegexMatchFlags match_options); 0526 GLIB_AVAILABLE_IN_ALL 0527 gchar **g_regex_split_full (const GRegex *regex, 0528 const gchar *string, 0529 gssize string_len, 0530 gint start_position, 0531 GRegexMatchFlags match_options, 0532 gint max_tokens, 0533 GError **error); 0534 0535 /* String replacement. */ 0536 GLIB_AVAILABLE_IN_ALL 0537 gchar *g_regex_replace (const GRegex *regex, 0538 const gchar *string, 0539 gssize string_len, 0540 gint start_position, 0541 const gchar *replacement, 0542 GRegexMatchFlags match_options, 0543 GError **error); 0544 GLIB_AVAILABLE_IN_ALL 0545 gchar *g_regex_replace_literal (const GRegex *regex, 0546 const gchar *string, 0547 gssize string_len, 0548 gint start_position, 0549 const gchar *replacement, 0550 GRegexMatchFlags match_options, 0551 GError **error); 0552 GLIB_AVAILABLE_IN_ALL 0553 gchar *g_regex_replace_eval (const GRegex *regex, 0554 const gchar *string, 0555 gssize string_len, 0556 gint start_position, 0557 GRegexMatchFlags match_options, 0558 GRegexEvalCallback eval, 0559 gpointer user_data, 0560 GError **error); 0561 GLIB_AVAILABLE_IN_ALL 0562 gboolean g_regex_check_replacement (const gchar *replacement, 0563 gboolean *has_references, 0564 GError **error); 0565 0566 /* Match info */ 0567 GLIB_AVAILABLE_IN_ALL 0568 GRegex *g_match_info_get_regex (const GMatchInfo *match_info); 0569 GLIB_AVAILABLE_IN_ALL 0570 const gchar *g_match_info_get_string (const GMatchInfo *match_info); 0571 0572 GLIB_AVAILABLE_IN_ALL 0573 GMatchInfo *g_match_info_ref (GMatchInfo *match_info); 0574 GLIB_AVAILABLE_IN_ALL 0575 void g_match_info_unref (GMatchInfo *match_info); 0576 GLIB_AVAILABLE_IN_ALL 0577 void g_match_info_free (GMatchInfo *match_info); 0578 GLIB_AVAILABLE_IN_ALL 0579 gboolean g_match_info_next (GMatchInfo *match_info, 0580 GError **error); 0581 GLIB_AVAILABLE_IN_ALL 0582 gboolean g_match_info_matches (const GMatchInfo *match_info); 0583 GLIB_AVAILABLE_IN_ALL 0584 gint g_match_info_get_match_count (const GMatchInfo *match_info); 0585 GLIB_AVAILABLE_IN_ALL 0586 gboolean g_match_info_is_partial_match (const GMatchInfo *match_info); 0587 GLIB_AVAILABLE_IN_ALL 0588 gchar *g_match_info_expand_references(const GMatchInfo *match_info, 0589 const gchar *string_to_expand, 0590 GError **error); 0591 GLIB_AVAILABLE_IN_ALL 0592 gchar *g_match_info_fetch (const GMatchInfo *match_info, 0593 gint match_num); 0594 GLIB_AVAILABLE_IN_ALL 0595 gboolean g_match_info_fetch_pos (const GMatchInfo *match_info, 0596 gint match_num, 0597 gint *start_pos, 0598 gint *end_pos); 0599 GLIB_AVAILABLE_IN_ALL 0600 gchar *g_match_info_fetch_named (const GMatchInfo *match_info, 0601 const gchar *name); 0602 GLIB_AVAILABLE_IN_ALL 0603 gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info, 0604 const gchar *name, 0605 gint *start_pos, 0606 gint *end_pos); 0607 GLIB_AVAILABLE_IN_ALL 0608 gchar **g_match_info_fetch_all (const GMatchInfo *match_info); 0609 0610 G_END_DECLS 0611 0612 #endif /* __G_REGEX_H__ */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|