|
|
| version 1.152, 2002/04/10 09:53:15 | version 1.153, 2002/04/19 07:59:51 |
|---|---|
| Line 441 void String::split(Array& result, | Line 441 void String::split(Array& result, |
| } | } |
| } | } |
| static void regex_options(char *options, int *result){ | static void regex_options(const String *options, int *result){ |
| struct Regex_option { | struct Regex_option { |
| char key; | const char *keyL; |
| const char *keyU; | |
| int clear, set; | int clear, set; |
| int *result; | int *result; |
| } regex_option[]={ | } regex_option[]={ |
| {'i', 0, PCRE_CASELESS, result}, // a=A | {"i", "I", 0, PCRE_CASELESS, result}, // a=A |
| {'s', 0, PCRE_DOTALL, result}, // \n\n$ [default] | {"s", "S", 0, PCRE_DOTALL, result}, // \n\n$ [default] |
| {'x', 0, PCRE_EXTENDED, result}, // whitespace in regex ignored | {"x", "U", 0, PCRE_EXTENDED, result}, // whitespace in regex ignored |
| {'m', PCRE_DOTALL, PCRE_MULTILINE, result}, // ^aaa\n$^bbb\n$ | {"m", "M", PCRE_DOTALL, PCRE_MULTILINE, result}, // ^aaa\n$^bbb\n$ |
| {'g', 0, true, result+1}, // many rows | {"g", "G", 0, true, result+1}, // many rows |
| {0}, | {0}, |
| }; | }; |
| result[0]=PCRE_EXTRA | PCRE_DOTALL; | result[0]=PCRE_EXTRA | PCRE_DOTALL; |
| result[1]=0; | result[1]=0; |
| if(options) | if(options) |
| for(Regex_option *o=regex_option; o->key; o++) | for(Regex_option *o=regex_option; o->keyL; o++) |
| if( | if( |
| strchr(options, o->key) || | options->pos(o->keyL)>=0 || |
| strchr(options, toupper(o->key))) { | options->pos(o->keyU)>=0) { |
| *(o->result)&=~o->clear; | *(o->result)&=~o->clear; |
| *(o->result)|=o->set; | *(o->result)|=o->set; |
| } | } |
| Line 483 bool String::match( | Line 484 bool String::match( |
| const char *pattern=regexp.cstr(); | const char *pattern=regexp.cstr(); |
| const char *errptr; | const char *errptr; |
| int erroffset; | int erroffset; |
| int option_bits[2]; regex_options(options?options->cstr():0, option_bits); | int option_bits[2]; regex_options(options, option_bits); |
| if(was_global) | if(was_global) |
| *was_global=option_bits[1]!=0; | *was_global=option_bits[1]!=0; |
| pcre *code=pcre_compile(pattern, option_bits[0], | pcre *code=pcre_compile(pattern, option_bits[0], |