blob: 9dc0fed3b3f8247b79e752fe9952d35ccea80985 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstra715ec202025-07-09 22:18:31 +02002 #include <regexp.h>
3
Zesstrad59c3892019-11-28 20:53:39 +01004 string * regexp(string *list, string pattern)
Zesstra715ec202025-07-09 22:18:31 +02005 string * regexp(string *list, string pattern, int opt)
MG Mud User88f12472016-06-24 23:31:02 +02006
Zesstra715ec202025-07-09 22:18:31 +02007DESCRIPTION
8 Match the pattern <pattern> (interpreted according to <opt> if
9 given) against all strings in list, and return a new array with all
10 strings that matched.
MG Mud User88f12472016-06-24 23:31:02 +020011
Zesstra715ec202025-07-09 22:18:31 +020012 If there is an error in the regular expression, a runtime
13 error will be raised.
MG Mud User88f12472016-06-24 23:31:02 +020014
Zesstra715ec202025-07-09 22:18:31 +020015EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020016 string strs;
Zesstra715ec202025-07-09 22:18:31 +020017 string pattern;
18
19 if (regexp_package() == RE_PCRE)
20 pattern = "\\<help\\>.*\\<me\\>";
21 else
22 pattern = "\\bhelp\\b.*\\bme\\b";
23
24 if (strs = regexp(({"please, help me Sir John."}), pattern)) {
25 if (sizeof(strs)
26 write("It matches.\n");
MG Mud User88f12472016-06-24 23:31:02 +020027 }
28
Zesstra715ec202025-07-09 22:18:31 +020029 The regular expression will test the given string (which is
30 packed into an array) if there is something like "help ... me"
31 inside of it.
MG Mud User88f12472016-06-24 23:31:02 +020032
Zesstra715ec202025-07-09 22:18:31 +020033HISTORY
34 LDMud 3.3 added the optional <opt> argument.
35 Since 3.5.0 a error is raised if RE_PCRE is specified in <opt>, but
36 the driver lacks PCRE support.
MG Mud User88f12472016-06-24 23:31:02 +020037
Zesstra715ec202025-07-09 22:18:31 +020038SEE ALSO
39 regexplode(E), regmatch(E), regreplace(E), regexp_package(E), sscanf(E),
40 regexp(C)