Macromedia dreamweaver 8-extending dreamweaver User Manual
338
Server Behaviors
Regular expressions
You must understand regular expressions as they are implemented in JavaScript 1.5. You must
also know when it is appropriate to use them in the server behavior EDML files. For example,
regular expressions cannot be used in
also know when it is appropriate to use them in the server behavior EDML files. For example,
regular expressions cannot be used in
quickSearch
values, but they are used in the content of
the
searchPattern
tag to find and extract data.
Regular expressions describe text strings by using characters that are assigned with special
meanings (metacharacters) to represent the text, break it up, and process it according to
predefined rules. Regular expressions are powerful parsing and processing tools because they
provide a generalized way to represent a pattern.
meanings (metacharacters) to represent the text, break it up, and process it according to
predefined rules. Regular expressions are powerful parsing and processing tools because they
provide a generalized way to represent a pattern.
Good reference books on JavaScript 1.5 have a regular expression section or chapter. This
section examines how Dreamweaver server behavior EDML files use regular expressions in
order to find parameters in your runtime code and extract their values. Each time a user edits
a server behavior, prior parameter values need to be extracted from the instances of the
runtime code. You use regular expressions for the extraction process.
section examines how Dreamweaver server behavior EDML files use regular expressions in
order to find parameters in your runtime code and extract their values. Each time a user edits
a server behavior, prior parameter values need to be extracted from the instances of the
runtime code. You use regular expressions for the extraction process.
You should understand a few metacharacters and metasequences (special character groupings)
that are useful in server behavior EDML files, as described in the following table:
that are useful in server behavior EDML files, as described in the following table:
The EDML tag
<searchPatterns whereToSearch="directive">
declares that runtime
code needs to be searched. Each
<searchPattern>...</searchPattern>
subtag defines one
pattern in the runtime code that must be identified. For the Redirect If Empty example, there
are two patterns.
are two patterns.
In the following example, to extract parameter values from
<% if (@@rs@@.EOF)
Response.Redirect("@@new__url@@"); %>,
write a regular expression that identifies any
string
rs
and
new__url
:
<searchPattern paramNames="rs,new__url">
/if d ((\w+)\.EOF\) Response\.Redirect\("([^\r\n]*)"\)/i
</searchPattern>
Regular Expression
Description
\
Escapes special characters. For example: \. reverts the
metacharacter back to a literal period; \/ reverts the forward slash
to its literal meaning; and, \) reverts the parens to its literal
meaning.
metacharacter back to a literal period; \/ reverts the forward slash
to its literal meaning; and, \) reverts the parens to its literal
meaning.
/ ... /i
Ignore case when searching for the metasequence
( ...)
Creates a parenthetical subexpression within the metasequence
\s*
Searches for white spaces