| regexp |
(String pattern [, int flags]) |
yoix.re |
| |
Creates a
Regexp
object from the supplied
pattern
string and optional type
flags.
regexp
is supplied purely as a convenience to make in-line use of regular
expressions more compact.
If there is a problem creating the
Regexp
object,
NULL
is returned.
| |
| Example: |
Since the
case
portion of a
switch
statement can be any expression, the following example shows how using
regexp
might be preferable to using the usual
new Regexp { ... }
approach.
import yoix.re.*;
import yoix.stdio.*;
regtest(arg) {
printf("For \"%s\", ", arg);
switch(arg) {
case regexp("^aaa"):
printf("matched #^aaa#.\n");
break;
case regexp(".*abc$"):
printf("matched #.*abc$#.\n");
break;
case regexp("Now .* good men"):
printf("matched #Now .* good men#.\n");
break;
default:
printf("there was no match.\n");
break;
}
}
regtest("dsasdasdabc");
regtest("aab");
regtest("Now is the ... good men");
regtest("aaabcd");
The result on standard output is:
For "dsasdasdabc", matched #.*abc$#.
For "aab", there was no match.
For "Now is the ... good men", matched #Now .* good men#.
For "aaabcd", matched #^aaa#.
| | |
| Return: |
Regexp
| | |
| See Also: |
gsubsti,
gvsubsti,
regexec,
Regexp,
regsub,
Subexp,
substi,
vsubsti
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|