php-src/ext/mbstring/oniguruma/doc/API

280 lines
7.4 KiB
Plaintext

Oniguruma API 2003/07/04
declared in regex.h.
# int regex_init(void)
Initialize library.
You don't have to call it explicitly, because it is called in regex_new().
# int regex_error_code_to_str(UChar* err_buf, int err_code, ...)
Return error message string length.
arguments
1 err_buf: error message buffer.
(required size: REG_MAX_ERROR_MESSAGE_LEN)
2 err_code: error code returned from other API functions.
3 err_info (optional): error info returned from regex_new()
and regex_recompile().
# int regex_new(regex_t** reg, UChar* pattern, UChar* pattern_end,
RegOptionType option, RegCharEncoding code, RegSyntaxType* syntax,
RegErrorInfo* err_info)
Create new regex object(regex_t).
normal return: REG_NORMAL
arguments
1 reg: return regex object's address.
2 pattern: regex pattern string.
3 pattern_end: terminate address of pattern. (pattern + pattern length)
4 option: compile time options.
REG_OPTION_NONE no option
REG_OPTION_SINGLELINE '^' -> '\A', '$' -> '\z', '\Z' -> '\z'
REG_OPTION_MULTILINE '.' match with newline
REG_OPTION_IGNORECASE ignore case (case-insensitive)
REG_OPTION_EXTEND extended pattern form
REG_OPTION_FIND_LONGEST find longest match
REG_OPTION_FIND_NOT_EMPTY ignore empty match
REG_OPTION_NEGATE_SINGLELINE
clear REG_OPTION_SINGLELINE which is default on
in REG_SYNTAX_POSIX_XXX, REG_SYNTAX_PERL and REG_SYNTAX_JAVA.
REG_OPTION_CAPTURE_ONLY_NAMED_GROUP named group only captured.
5 code: character encoding.
REGCODE_ASCII ASCII
REGCODE_UTF8 UTF-8
REGCODE_EUCJP EUC-JP
REGCODE_SJIS Shift_JIS
REGCODE_DEFAULT ASCII
6 syntax: pointer to pattern syntax definition.
REG_SYNTAX_POSIX_BASIC POSIX Basic RE
REG_SYNTAX_POSIX_EXTENDED POSIX Extended RE
REG_SYNTAX_EMACS Emacs
REG_SYNTAX_GREP grep
REG_SYNTAX_GNU_REGEX GNU regex
REG_SYNTAX_JAVA Java (Sun java.util.regex)
REG_SYNTAX_PERL Perl
REG_SYNTAX_RUBY Ruby
REG_SYNTAX_DEFAULT default (== Ruby)
regex_set_default_syntax()
or any RegSyntaxType data pointer defined by user.
7 err_info: address for return optional error info.
use this value as 3rd argument of regex_error_code_to_str().
# void regex_free(regex_t* reg)
Free memory used by regex object.
arguments
1 reg: regex object.
# int regex_recompile(regex_t* reg, UChar* pattern, UChar* pattern_end,
RegOptionType option, RegCharEncoding code, RegSyntaxType* syntax,
RegErrorInfo* err_info)
Recompile regex object.
normal return: REG_NORMAL
arguments
1 reg: regex object.
Another arguments are same with regex_new().
# int regex_search(regex_t* reg, UChar* str, UChar* end, UChar* start,
UChar* range, RegRegion* region, RegOptionType option)
Search string and return search result and matching region.
normal return: match position offset (i.e. p - str >= 0)
not found: REG_MISMATCH (< 0)
arguments
1 reg: regex object
2 str: target string
3 end: terminate address of target string
4 start: search start address of target string
5 range: search terminate address of target string
6 region: address for return group match range info (NULL is allowed)
7 option: search time option
REG_OPTION_NOTBOL string head(str) isn't considered as begin of line
REG_OPTION_NOTEOL string end (end) isn't considered as end of line
REG_OPTION_POSIX_REGION region argument is regmatch_t[] of POSIX API.
# int regex_match(regex_t* reg, UChar* str, UChar* end, UChar* at,
RegRegion* region, RegOptionType option)
Match string and return result and matching region.
normal return: match length (i.e. p - at >= 0)
not match: REG_MISMATCH (< 0)
arguments
1 reg: regex object
2 str: target string
3 end: terminate address of target string
4 at: match address of target string
5 region: address for return group match range info (NULL is allowed)
6 option: search time option
REG_OPTION_NOTBOL string head(str) isn't considered as begin of line
REG_OPTION_NOTEOL string end (end) isn't considered as end of line
REG_OPTION_POSIX_REGION region argument is regmatch_t[] of POSIX API.
# RegRegion* regex_region_new(void)
Create a region.
# void regex_region_free(RegRegion* region, int free_self)
Free memory used by region.
arguments
1 region: target region
2 free_self: [1: free all, 0: free memory used in region but not self]
# void regex_region_copy(RegRegion* to, RegRegion* from)
Copy contents of region.
arguments
1 to: target region
2 from: source region
# void regex_region_clear(RegRegion* region)
Clear contents of region.
arguments
1 region: target region
# int regex_region_resize(RegRegion* region, int n)
Resize group range area of region.
normal return: REG_NORMAL
arguments
1 region: target region
2 n: new size
# int regex_name_to_group_numbers(regex_t* reg, UChar* name, UChar* name_end,
int** num_list)
Return group number list of name.
Named subexp is defined by (?<name>....).
normal return: number of groups for the name.
(ex. /(?<x>..)...(?<x>..)/ ==> 2)
name not found: -1
arguments
1 reg: regex object.
2 name: subexp-name.
3 name_end: terminate address of subexp-name.
4 num_list: return list of group number.
# int regex_foreach_names(regex_t* reg, int (*func)(UChar*,int,int*,void*),
void* arg)
Iterate function call for all names.
normal return: 0
error: func's return value.
arguments
1 reg: regex object.
2 func: called function.
func(name, <number of groups>, <group number's list>, arg);
if func return non 0 value, iteration is stopped.
3 arg: argument for func.
# UChar* regex_get_prev_char_head(RegCharEncoding code, UChar* start, UChar* s)
Return previous character head address.
arguments
1 code: character encoding
2 start: string address
3 s: target address of string
# UChar* regex_get_left_adjust_char_head(RegCharEncoding code,
UChar* start, UChar* s)
Return left-adjusted head address of a character.
arguments
1 code: character encoding
2 start: string address
3 s: target address of string
# UChar* regex_get_right_adjust_char_head(RegCharEncoding code,
UChar* start, UChar* s)
Return right-adjusted head address of a character.
arguments
1 code: character encoding
2 start: string address
3 s: target address of string
# int regex_set_default_syntax(RegSyntaxType* syntax)
Set default syntax.
arguments
1 syntax: pointer to pattern syntax definition.
# void regex_set_default_trans_table(UChar* table)
Set default case transformation table.
arguments
1 table: case transformation table
(* this function will be obsoleted in future version)
# int regex_end(void)
The use of this library is finished.
normal return: REG_NORMAL
# const char* regex_version(void)
Return version string. (ex. "1.8.6")
// END