Project

General

Profile

Normal Api » History » Revision 2

Revision 1 (iri, 02/23/2011 11:52 PM) → Revision 2/6 (iri, 02/24/2011 12:03 AM)

h1. Normal Api 

 These functions are more complexes. If they are not required by your work, don't use it ! 

 First, these flags are availables : 

 h3. CompileFlags : 

 * PCRE_REGEX_CASELESS 
 Letters in the pattern match both upper- and lowercase letters. This option can be changed within a pattern by a "(?i)" option setting.  
 * PCRE_REGEX_MULTILINE 
 By default, GRegex treats the strings as consisting of a single line of characters (even if it actually contains newlines). The "start of line" metacharacter ("^") matches only at the start of the string, while the "end of line" metacharacter ("$") matches only at the end of the string, or before a terminating newline (unless G_REGEX_DOLLAR_ENDONLY is set). When G_REGEX_MULTILINE is set, the "start of line" and "end of line" constructs match immediately following or immediately before any newline in the string, respectively, as well as at the very start and end. This can be changed within a pattern by a "(?m)" option setting.  
 * PCRE_REGEX_DOTALL 
 A dot metacharater (".") in the pattern matches all characters, including newlines. Without it, newlines are excluded. This option can be changed within a pattern by a ("?s") option setting.  
 * PCRE_REGEX_EXTENDED 
 Whitespace data characters in the pattern are totally ignored except when escaped or inside a character class. Whitespace does not include the VT character (code 11). In addition, characters between an unescaped "#" outside a character class and the next newline character, inclusive, are also ignored. This can be changed within a pattern by a "(?x)" option setting.  
 * PCRE_REGEX_ANCHORED 
 The pattern is forced to be "anchored", that is, it is constrained to match only at the first matching point in the string that is being searched. This effect can also be achieved by appropriate constructs in the pattern itself such as the "^" metacharater.  
 * PCRE_REGEX_DOLLAR_ENDONLY 
 A dollar metacharacter ("$") in the pattern matches only at the end of the string. Without this option, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines). This option is ignored if G_REGEX_MULTILINE is set. 
 * PCRE_REGEX_UNGREEDY 
 Inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by "?". It can also be set by a "(?U)" option setting within the pattern.  
 * PCRE_REGEX_RAW 
 Usually strings must be valid UTF-8 strings, using this flag they are considered as a raw sequence of bytes. 
 * PCRE_REGEX_NO_AUTO_CAPTURE 
 Disables the use of numbered capturing parentheses in the pattern. Any opening parenthesis that is not followed by "?" behaves as if it were followed by "?:" but named parentheses can still be used for capturing (and they acquire numbers in the usual way).  
 * PCRE_REGEX_OPTIMIZE 
 Optimize the regular expression. If the pattern will be used many times, then it may be worth the effort to optimize it to improve the speed of matches.  
 * PCRE_REGEX_DUPNAMES 
 Names used to identify capturing subpatterns need not be unique. This can be helpful for certain types of pattern when it is known that only one instance of the named subpattern can ever be matched.  
 * PCRE_REGEX_NEWLINE_CR 
 Usually any newline character is recognized, if this option is set, the only recognized newline character is '\r'.  
 * PCRE_REGEX_NEWLINE_LF 
 Usually any newline character is recognized, if this option is set, the only recognized newline character is '\n'.  
 * PCRE_REGEX_NEWLINE_CRLF 
 Usually any newline character is recognized, if this option is set, the only recognized newline character sequence is '\r\n'.  

 h3. MatchFlags : 

 * PCRE_MATCH_ANCHORED 
 The pattern is forced to be "anchored", that is, it is constrained to match only at the first matching point in the string that is being searched. This effect can also be achieved by appropriate constructs in the pattern itself such as the "^" metacharater.  
 * PCRE_MATCH_NOTBOL 
 Specifies that first character of the string is not the beginning of a line, so the circumflex metacharacter should not match before it. Setting this without G_REGEX_MULTILINE (at compile time) causes circumflex never to match. This option affects only the behaviour of the circumflex metacharacter, it does not affect "\A".  
 * PCRE_MATCH_NOTEOL 
 Specifies that the end of the subject string is not the end of a line, so the dollar metacharacter should not match it nor (except in multiline mode) a newline immediately before it. Setting this without G_REGEX_MULTILINE (at compile time) causes dollar never to match. This option affects only the behaviour of the dollar metacharacter, it does not affect "\Z" or "\z".  
 * PCRE_MATCH_NOTEMPTY 
 An empty string is not considered to be a valid match if this option is set. If there are alternatives in the pattern, they are tried. If all the alternatives match the empty string, the entire match fails. For example, if the pattern "a?b?" is applied to a string not beginning with "a" or "b", it matches the empty string at the start of the string. With this flag set, this match is not valid, so GRegex searches further into the string for occurrences of "a" or "b".  
 * PCRE_MATCH_PARTIAL 
 Turns on the partial matching feature, for more documentation on partial matching 
 * PCRE_MATCH_NEWLINE_CR 
 Overrides the newline definition set when creating a new GRegex, setting the '\r' character as line terminator.  
 * PCRE_MATCH_NEWLINE_LF 
 Overrides the newline definition set when creating a new GRegex, setting the '\n' character as line terminator. 
 * PCRE_MATCH_NEWLINE_CRLF 
 Overrides the newline definition set when creating a new GRegex, setting the '\r\n' characters as line terminator.  
 * PCRE_MATCH_NEWLINE_ANY 
 Overrides the newline definition set when creating a new GRegex, any newline character or character sequence is recognized.  

 Explanations (above) from these flags from the GLib's documentations. 

 h3. AlgoFlag 

 Algorithm to match : 
 * PCRE_MATCH_STANDARD : standard 
 * PCRE_MATCH_DFA : DFA (Deterministic Finite Automaton) 

 Now, the functions are listed below. 

 


 h2. _pcreNormalMatch 

 Scans for a match in string for the pattern. 

 Prototype : *fun fun [S S I I I I] [[S I I] r1]* 

 # S : pattern 
 # S : string 
 # I : compileflag, (see above) or nil (nothing) 
 # I : start, starting index of the string to match 
 # I : matchflag, (see above) or nil (nothing) 
 # I : algoflag, (see above) 
 +Return+ : [[S I I] r1] : a list, each element is a tuple : the matched word, the start position where it has been found, the end position 
 nil if error. 

 h2. _pcreNormalSplit 

 Breaks the string on the pattern, and returns a list of the tokens. 

 Prototype : *fun [S S I I I I] [S r1]* 

 # S : pattern 
 # S : string 
 # I : compileflag, (see above) or nil (nothing) 
 # I : start, starting index of the string to match 
 # I : matchflag, (see above) or nil (nothing) 
 # I : max, the maximum number of tokens to split string into. If this is less than 1, the string is split completely 
 +Return+ : [S r1] : a list of broken string or nil if error. 

 h2. _pcreNormalReplace 

 Replaces all occurrences of the pattern in string with a replacement text. 

 Prototype : 

 Return [[API]]