PCRE2CONVERT - Online Linux Manual PageSection : 3
Updated : 28 June 2018
Source : PCRE2 10.32
NAMEPCRE2 - Perl-compatible regular expressions (revised API)
EXPERIMENTAL PATTERN CONVERSION FUNCTIONS\.sp This document describes a set of functions that can be used to convert "foreign" patterns into PCRE2 regular expressions. This facility is currently experimental, and may be changed in future releases. Two kinds of pattern, globs and POSIX patterns, are supported.
THE CONVERT CONTEXT\.sp pcre2_convert_context *pcre2_convert_context_create(
pcre2_general_context *gcontext);"
pcre2_convert_context *pcre2_convert_context_copy(
pcre2_convert_context *cvcontext);"
void pcre2_convert_context_free(pcre2_convert_context *cvcontext);
int pcre2_set_glob_escape(pcre2_convert_context *cvcontext,
uint32_t escape_char);"
int pcre2_set_glob_separator(pcre2_convert_context *cvcontext,
uint32_t separator_char);"A convert context is used to hold parameters that affect the way that pattern conversion works. Like all PCRE2 contexts, you need to use a context only if you want to override the defaults. There are the usual create, copy, and free functions. If custom memory management functions are set in a general context that is passed to pcre2_convert_context_create(), they are used for all memory management within the conversion functions. There are only two parameters in the convert context at present. Both apply only to glob conversions. The escape character defaults to grave accent under Windows, otherwise backslash. It can be set to zero, meaning no escape character, or to any punctuation character with a code point less than 256. The separator character defaults to backslash under Windows, otherwise forward slash. It can be set to forward slash, backslash, or dot. The two setting functions return zero on success, or PCRE2_ERROR_BADDATA if their second argument is invalid.
THE CONVERSION FUNCTION\.sp int pcre2_pattern_convert(PCRE2_SPTR pattern, PCRE2_SIZE length,
uint32_t options, PCRE2_UCHAR **buffer,"
PCRE2_SIZE *blength, pcre2_convert_context *cvcontext);"
void pcre2_converted_pattern_free(PCRE2_UCHAR *converted_pattern);The first two arguments of pcre2_pattern_convert() define the foreign pattern that is to be converted. The length may be given as PCRE2_ZERO_TERMINATED. The options argument defines how the pattern is to be processed. If the input is UTF, the PCRE2_CONVERT_UTF option should be set. PCRE2_CONVERT_NO_UTF_CHECK may also be set if you are sure the input is valid. One or more of the glob options, or one of the following POSIX options must be set to define the type of conversion that is required:
PCRE2_CONVERT_GLOB
PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR
PCRE2_CONVERT_GLOB_NO_STARSTAR
PCRE2_CONVERT_POSIX_BASIC
PCRE2_CONVERT_POSIX_EXTENDED Details of the conversions are given below. The buffer and blength arguments define how the output is handled: If buffer is NULL, the function just returns the length of the converted pattern via blength. This is one less than the length of buffer needed, because a terminating zero is always added to the output. If buffer points to a NULL pointer, an output buffer is obtained using the allocator in the context or malloc() if no context is supplied. A pointer to this buffer is placed in the variable to which buffer points. When no longer needed the output buffer must be freed by calling pcre2_converted_pattern_free(). If this function is called with a NULL argument, it returns immediately without doing anything. If buffer points to a non-NULL pointer, blength must be set to the actual length of the buffer provided (in code units). In all cases, after successful conversion, the variable pointed to by blength is updated to the length actually used (in code units), excluding the terminating zero that is always added. If an error occurs, the length (via blength) is set to the offset within the input pattern where the error was detected. Only gross syntax errors are caught; there are plenty of errors that will get passed on for pcre2_compile() to discover. The return from pcre2_pattern_convert() is zero on success or a non-zero PCRE2 error code. Note that PCRE2 error codes may be positive or negative: pcre2_compile() uses mostly positive codes and pcre2_match() negative ones; pcre2_convert() uses existing codes of both kinds. A textual error message can be obtained by calling pcre2_get_error_message().
CONVERTING GLOBS\.sp Globs are used to match file names, and consequently have the concept of a "path separator", which defaults to backslash under Windows and forward slash otherwise. If PCRE2_CONVERT_GLOB is set, the wildcards * and ? are not permitted to match separator characters, but the double-star (**) feature (which does match separators) is supported. PCRE2_CONVERT_GLOB_NO_WILD_SEPARATOR matches globs with wildcards allowed to match separator characters. PCRE2_CONVERT_GLOB_NO_STARSTAR matches globs with the double-star feature disabled. These options may be given together.
CONVERTING POSIX PATTERNS\.sp POSIX defines two kinds of regular expression pattern: basic and extended. These can be processed by setting PCRE2_CONVERT_POSIX_BASIC or PCRE2_CONVERT_POSIX_EXTENDED, respectively. In POSIX patterns, backslash is not special in a character class. Unmatched closing parentheses are treated as literals. In basic patterns, ? + | {} and () must be escaped to be recognized as metacharacters outside a character class. If the first character in the pattern is * it is treated as a literal. ^ is a metacharacter only at the start of a branch. In extended patterns, a backslash not in a character class always makes the next character literal, whatever it is. There are no backreferences. Note: POSIX mandates that the longest possible match at the first matching position must be found. This is not what pcre2_match() does; it yields the first match that is found. An application can use pcre2_dfa_match() to find the longest match, but that does not support backreferences (but then neither do POSIX extended patterns).
AUTHOR\.sp Philip Hazel
University Computing Service
Cambridge, England.
REVISION\.sp Last updated: 28 June 2018
Copyright (c) 1997-2018 University of Cambridge. 0
Johanes Gumabo
Data Size : 15,530 byte
man-pcre2convert.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 192,836
Visitor ID : :
Visitor IP : 18.224.43.98 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.