File: spec_8.html

package info (click to toggle)
exim-html 3.20-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge, woody
  • size: 2,868 kB
  • ctags: 4,188
  • sloc: makefile: 40; sh: 19
file content (86 lines) | stat: -rw-r--r-- 3,144 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52
     from spec on 25 November 2000 -->

<TITLE>Exim Specification - 8. Regular expressions</TITLE>
</HEAD>
<body bgcolor="#FFFFFF" text="#00005A" link="#FF6600" alink="#FF9933" vlink="#990000">
Go to the <A HREF="spec_1.html">first</A>, <A HREF="spec_7.html">previous</A>, <A HREF="spec_9.html">next</A>, <A HREF="spec_59.html">last</A> section, <A HREF="spec_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC174" HREF="spec_toc.html#TOC174">8. Regular expressions</A></H1>

<P>
<A NAME="IDX523"></A>
Exim uses the PCRE regular expression library; this provides regular expression
matching that is compatible with Perl 5. The syntax and semantics of these
regular expressions is discussed in many Perl reference books, and also in
Jeffrey Friedl's <EM>Mastering Regular Expressions</EM>  (O'Reilly, ISBN
1-56592-257-3).

</P>
<P>
<font color=green>
The documentation for PCRE, in plain text and HTML, is included in the <EM>doc</EM>
directory of the Exim distribution. This describes the features of the regular
expressions that PCRE supports, so no further description is included here. The
PCRE functions are called from Exim using the default option settings, except
that the PCRE_CASELESS option is set when the matching is required to be
independent of the case of letters.
</font>

</P>

<P>



<H2><A NAME="SEC175" HREF="spec_toc.html#TOC175">8.1 Testing regular expressions</A></H2>

<P>
<A NAME="IDX524"></A>
A program called <EM>pcretest</EM> forms part of the PCRE distribution and is built
with PCRE during the process of building Exim. It is primarily intended for
testing PCRE itself, but it can also be used for experimenting with regular
expressions. The binary can be found in the
<font color=green>
<EM>util</EM> sub-directory of the Exim build directory. There is documentation of
various options in <EM>doc/pcretest.txt</EM>,
</font>
but for simple testing, none are needed. This is the output of a sample run of
<EM>pcretest</EM>:

<PRE>
  re&#62; /^([^@]+)@.+\.(ac|edu)\.(?!kr)[a-z]{2}$/
data&#62; x@y.ac.uk
 0: x@y.ac.uk
 1: x
 2: ac
data&#62; x@y.ac.kr
No match
data&#62; x@y.edu.com
No match
data&#62; x@y.edu.co
 0: x@y.edu.co
 1: x
 2: edu
</PRE>

<P>
After the `re&#62;' prompt, a regular expression enclosed in delimiters is
expected. If this compiles without error, `data&#62;' prompts are given for strings
against which the expression is matched. An empty data line causes a new
regular expression to be read. If the match is successful, the captured
substring values (that is, what would be in the variables $<EM>0</EM>, $<EM>1</EM>, $<EM>2</EM>,
etc.) are shown. The above example tests for an email address whose domain ends
with either `ac' or `edu' followed by a two-character top-level domain that is
not `kr'. The local part is captured in $<EM>1</EM> and the `ac' or `edu' in $<EM>2</EM>.

</P>

<P><HR><P>
Go to the <A HREF="spec_1.html">first</A>, <A HREF="spec_7.html">previous</A>, <A HREF="spec_9.html">next</A>, <A HREF="spec_59.html">last</A> section, <A HREF="spec_toc.html">table of contents</A>.
</BODY>
</HTML>