Next, the
searchPattern
and extracts parameter values from the participant code. The search patterns specify where to
search (the
whereToSearch
patterns. These patterns can use simple strings or regular expressions. The previous example code
is an ASP directive, so the
identifies the directive and extracts the parameters, as shown in the following example:
<quickSearch>Response.Write</quickSearch>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="rs,new__url">
/if\s*\((\w+)\.EOF\)\s*Response\.Redirect\("([^\r\n]*)"\)/i
</searchPattern>
</searchPatterns>
The search string is defined as a regular expression by starting and ending with a slash (/) and is
followed by
, which means that it is not case-sensitive. Within the regular expression, special
i
characters such as parentheses () and periods (.) are escaped by preceding them with a backslash
(\). The two parameters
subexpressions (the parameters must be enclosed in parentheses). In this example, they are
indicated by
and
(\w+)
that are normally returned by
Optional search patterns
if some parameters are not found. You might have a participant that stores some optional
information such as a telephone number. For such an example, you could use the following
ASP code:
<% //address block
LNAME = "joe";
FNAME = "smith";
PHONE = "123-4567";
%>
You could use the following search patterns:
<quickSearch>address</quickSearch>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="lname">/LNAME\s*=\s*"([^\r\n]*)"/i¬
</searchPattern>
<searchPattern paramNames="fname">/FNAME\s*=\s*"([^\r\n]*)"/i¬
</searchPattern>
<searchPattern paramNames="phone">/PHONE\s*=\s*"([^\r\n]*)"/i¬
</searchPattern>
</searchPatterns>
In the previous example, the telephone number must be specified. However, you can make
the telephone number optional, by adding the
following example:
<quickSearch>address</quickSearch>
<searchPatterns whereToSearch="directive">
<searchPattern paramNames="lname">/LNAME\s*=\s*"([^\r\n]*)"/i¬
</searchPattern>
<searchPattern paramNames="fname">/FNAME\s*=\s*"([^\r\n]*)"/i¬
</searchPattern>
<searchPattern paramNames="phone" isOptional="true">¬
/PHONE\s*=\s*"([^\r\n]*)"/i
</searchPattern>
</searchPatterns>
tag searches the document more precisely than the
attribute) with a series of
whereToSearch="directive"
and
are extracted from the string by using parenthetical
rs
new__url
: These values correspond to the regular expression values
([^\r\n]*)
and
.
$1
$2
There might be cases where you want to identify a participant even
searchPattern
specification and a regular expression
attribute, as shown in the
isOptional
Server behavior techniques
quickSearch
tags that contain specific
tag
287
Need help?
Do you have a question about the DREAMWEAVER MX 2004-EXTENDING DREAMWEAVER and is the answer not in the manual?