Welcome to Vestris Inc.
Internet Interactive Solutions Company



Software Documentation

Writing Expressions

Introduction

The Alkaline simple regular expressions extend mapping possibilities for search results. Extended tags, such as <!--name expression--> and options, such as <!--SET name--expression--> allow values in a special simple regexp form.

Expressions allow, for example, to show different output when no results were found. They also enable such advanced features as inserting a picture for search results from a particular location in the site. In either way, expressions help search templates designers to give their Alkaline users a look and feel of the site being searched.

Expression Variables

A variable name is a well defined entity beginning with a $ sign, followed by a series of alphanumeric elements, dots and dashes. Variables are used in Alkaline specific extended tags and options. For example, $url is a variable and is being translated into an url when used in a <!--SET MAP--expression--> option. For example:
<!--SET MAP--this is an url: $url-->

Variables use the following general syntax:
{$£}{name}[|COMMAND{PARAMETER}]~[Prefix]#[Postfix]^[Elsefix]
To output a variable value, simply use it with a $ sign, for example $url . To evaluate a variable, use it with a £ sign, for example £url~[Url is not empty!] . As you might have guessed, the final result will be "Url is not empty!" if the variable url contains any text and nothing will be output when it is empty.

Variable names can contain spaces and special characters. Such a variable should be used between brackets, for example $[Custom Meta Tag] .

In general, if the variable is empty, Elsefix is output. Otherwise, Prefix is inserted before and Postfix , after the variable value. Any of the three sections Prefix , Postfix or Elsefix can me omitted.

Expression Commands

Commands allow to pre-operate on the variable. This means that the variable value will be affected before it is checked for having any data for the Prefix , Postfix or Elsefix output. You can chain commands by separating them with a comma. Commands can be one, or a combination of the following:

Table 6-2. Expression Commands
TRIM remove leading and trailing spaces
TRIM32 remove leading and trailing spaces, carriage returns, tabs and line feeds
LEFT{SIZE} leave leftmost SIZE characters
RIGHT{SIZE} leave leftmost RIGHT characters
IS{STRING} clear if not STRING (case-sensitive)
NOT{STRING} clear if STRING (case-sensitive)
HAS{STRING} clear if does not contain STRING (case-insensitive)
STARTS{STRING} clear if does not start with STRING (case-insensitive)
ENDS{STRING} clear if does not end with STRING (case-insensitive)
REPLACE{SOURCE:TARGET} replace SOURCE with TARGET (case-sensitive) (added in version 1.7)
REPLACI{SOURCE:TARGET} replace SOURCE with TARGET (case-insensitive) (added in version 1.7)
UPCASE convert to upper-case
LCASE convert to lower-case
REVERSE reverse value
MORE{NUMBER} clear if term is smaller or equal to NUMBER (leave unchanged if more than NUMBER)
LESS{NUMBER} clear if term is bigger or equal to NUMBER (leave unchanged if less than NUMBER)
URLENCODE encode as an URL (eg. space becomes %20)
URLDECODE decode as an URL
HTMLQUOTE encode as html (eg. & becomes &amp;)
HTMLDEQUOTE decode as html
CLEFT{NUMBER} cut the NUMBER leftmost characters
CRIGHT{NUMBER} cut the NUMBER rightmost characters
URLSCH url scheme, such as http (added 02-Jul-2000)
URLHOST server name (added 02-Jul-2000)
URLDIR full document path, cannot be empty (added 02-Jul-2000)
URLFILE file name (added 02-Jul-2000)
URLARG parameters after ? (added 02-Jul-2000)

Examples

The easiest way to understand how expressions work in Alkaline is to look at examples with the following data:

Table 6-3. Variable Values
Variable Name Variable Value
search foo
url http://www.foo.com/bar/
dummy  
quant 10

Table 6-4. Expression Examples
Expression Output
$dummy~[Dummy is empty...]^[Dummy is not empty...] Dummy is empty...
Searching for "$search", $quant results found. Searching for "foo", 10 results found.
$quant~[Found ]#[ documents.]^[No documents found.] Found 10 documents.
£search~[Searching $search.]^[Nothing to search!] Searching foo.
$url|TRIM,LEFT10 http://www
$url|[REPLACEfoo:bar] http://www.bar.com/bar/
£url|[HASftp://]~[Ftp!]^ [£url|[STARTShttp://]~[Web!]] Web!