Software: Apache/2.0.54 (Unix) mod_perl/1.99_09 Perl/v5.8.0 mod_ssl/2.0.54 OpenSSL/0.9.7l DAV/2 FrontPage/5.0.2.2635 PHP/4.4.0 mod_gzip/2.0.26.1a uname -a: Linux snow.he.net 4.4.276-v2-mono-1 #1 SMP Wed Jul 21 11:21:17 PDT 2021 i686 uid=99(nobody) gid=98(nobody) groups=98(nobody) Safe-mode: OFF (not secure) /usr/doc/slang-1.4.5/html/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 18. Regular Expressions
The S-Lang library includes a regular expression (RE) package that may be used by an application embedding the library. The RE syntax should be familiar to anyone acquainted with regular expressions. In this section the syntax of the S-Lang regular expressions is discussed.
18.1 S-Lang RE Syntax
A regular expression specifies a pattern to be matched against a string, and has the property that the contcatenation of two REs is also a RE. The S-Lang library supports the following standard regular expressions:
In addition the following extensions are also supported:
Here are some simple examples:
A more complex pattern is
which matches any word repeated consecutively. Note how the grouping
operators \( and \) are used to define the text
matched by the enclosed regular expression, and then subsequently
referred to \1.
Finally, remember that when used in string literals either in the
S-Lang language or in the C language, care must be taken to
"double-up" the
18.2 Differences between S-Lang and egrep REs
There are several differences between S-Lang regular expressions and, e.g., egrep regular expressions. The most notable difference is that the S-Lang regular expressions do
not support the OR operator The other main difference is that while S-Lang regular expressions
support the grouping operators
matches "xxx@abc@silly@abc@yyy", where the pattern \1
matches the text enclosed by the \( and \)
expressions. However, in the current implementation, the grouping
operators are not used to group regular expressions to form a single
regular expression. Thus expression such as "\(hello\)*" is
not a pattern to match zero or more occurances of "hello"
as it is in e.g., egrep.
One question that comes up from time to time is why doesn't S-Lang simply employ some posix-compatible regular expression library. The simple answer is that, at the time of this writing, none exists that is is available across all the platforms that the S-Lang library supports (Unix, VMS, OS/2, win32, win16, BEOS, MSDOS, and QNX) and can be distributed under both the GNU and Artistic licenses. It is particularly important that the library and the interpreter support a common set of regular expressions in a platform independent manner.
Next Previous Contents |
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #13 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0098 ]-- |