MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | SYNOPSIS |
| 2 | #include <regexp.h> |
| 3 | |
| 4 | int regexp_package() |
| 5 | |
| 6 | DESCRIPTION |
| 7 | Return which regexp package is used by default: |
| 8 | |
| 9 | RE_TRADITIONAL: traditional regexps |
| 10 | RE_PCRE: PCRE |
| 11 | |
| 12 | As the package can be selected at runtime through the |
| 13 | REGEXP_PACKAGE driver hook, there is no good way to determine |
| 14 | the package at LPC compile time. |
| 15 | Match the pattern <pattern> (interpreted according to <opt> if |
| 16 | given) against all strings in list, and return a new array with all |
| 17 | strings that matched. |
| 18 | |
| 19 | If there is an error in the regular expression, a runtime |
| 20 | error will be raised. |
| 21 | |
| 22 | EXAMPLE |
| 23 | string strs; |
| 24 | string pattern; |
| 25 | |
| 26 | if (regexp_package() == RE_PCRE) |
| 27 | pattern = "\\<help\\>.*\\<me\\>"; |
| 28 | else |
| 29 | pattern = "\\bhelp\\b.*\\bme\\b"; |
| 30 | |
| 31 | if (strs = regexp( ({"please, help me Sir John."}), |
| 32 | , pattern |
| 33 | )) |
| 34 | { |
| 35 | if (sizeof(strs) |
| 36 | write("It matches.\n"); |
| 37 | } |
| 38 | |
| 39 | The regular expression will test the given string (which is |
| 40 | packed into an array) if there is something like "help ... me" |
| 41 | inside of it. |
| 42 | |
| 43 | HISTORY |
| 44 | Introduced in LDMud 3.3.634. |
| 45 | |
| 46 | SEE ALSO |
| 47 | regexp(E), regexplode(E), regmatch(E), regreplace(E), sscanf(E), |
| 48 | regexp(C), regexp_package(H) |