Sun Java System Portal Server Secure Remote Access 7.1 Administration Guide

Using Pattern Matching in Rules

You can use the valuePatterns field to achieve pattern matching and identify the specific parts of a statement that need to be rewritten.

If you have specified valuePatterns as part of a rule, all the content that follows the matched pattern is rewritten.

Consider the sample form rule below.

<Form source="*/source.html
" name="form1" field="visit
" [valuePatterns="0|1234|"]/>

where

source is the URL of the html page where the form displays

name is the name of the form

field is the field in the form whose value needs to be rewritten

valuePatterns indicates the portion of the string that needs to be rewritten. All content appearing after valuePatterns is rewritten (optional, default "" means the full value needs to be rewritten).

Specifying Specialized Characters in valuePatterns

You can specify specialized characters by escaping them with a backslash. For example:

<Form source="*/source.html" name="form1" field="visit" [valuePatterns="0|1234|\\;original text|changed text”]/>

Using Wild Cards in valuePatterns

You can use the * character to achieve pattern matching for rewriting.

You cannot specify just a * in the valuePatterns field. Because * indicates a match with everything, nothing will follow the valuePattern, and hence Rewriter will have nothing left to rewrite. You can use * in conjunction with another string such as *abc. In this case, all content that follows *abc is rewritten.


Note –

An asterisk (*) can be used as a wildcard in any of the fields of the rule. But all the fields in the rule cannot contain a *. If all fields contain a *, the rule is ignored. No error message is displayed.


You can use a * or ** along with the separation character (a semicolon or comma) that displays in the original statement to separate multiple fields. One wildcard (*) matches any field that is not to be rewritten, and two wildcards (**) match any field that needs to be rewritten.

Using Wild Cards in valuePatterns lists some sample usages of the * wildcard.

Table 3–1 Sample Usage of * Wildcard

URL 

valuePatterns 

Description 

url1, url2, url3, url4

valuePatterns = "**, *, **, *"

In this case, url1 and url3 are rewritten because ** indicates the portion to be rewritten

XYZABChttp://host1.sesta.com/dir1.html

valuePatterns = "*ABC"

In this case, only the portion http://host1.sesta.com/dir1.html is rewritten. Everything after *ABC needs to be rewritten.

"0|dir1|dir2|dir3|dir4|test|url1

valuePatterns = "*|*|**|*|**|*|"

In this case, dir2, dir4 and url1 are rewritten. The last field that needs to be rewritten does not have to be indicated by using **.