Replacement Strings

You can use replacement strings to replace data values with other data. A typical example is that some databases represent booleans as 0 and 1 but maybe the user would rather see no and yes or false and true. With the replacement string, you can define what a data value should look like to the user.

Simple Translations

The easiest way of translating one value to another is to use the syntax for a simple translation. In order to transform 0 and 1 to no and yes, you should write the following replacement string:

T:0=no,1=yes

You will notice the T: in the beginning of the replacement string. This tells the system that you are using a simple translation.

The replacement string will be searched from the beginning to the end. If no match is found, it will give an empty result. You can make sure that everything is matched by using a * as the thing to search for. The * will match anything and is usually used as the last thing to match in a replacement string. Here are some examples:

Replacement String Database Value Result
T:0=no,1=yes 1 yes
T:0=no,1=yes 3 (empty)
T:0=no,1=yes,*=maybe 3 maybe
T:0=no,1=yes,* 3 3
R:2=two$0two 123  
R:2=two$0two 456  
  456 456

Notice that if you leave out the replacement value for the *, it will use the original database value.

Regular Expressions

Sometimes the simple translations will not do the job. This is where the regular expressions come into action. If you are new to regular expressions, you can read about it at Microsoft's Regular Expression Language - Quick Reference. Working with regular expressions can be quite powerful and complicated at the same time.

All regular expression replacement strings must start with R: to tell that it should be interpreted as a regular expression replacement.

These are examples of regular expression replacement strings:

Replacement String Database Value Result
R:0=no,1=yes,^.*$=maybe 2 maybe
R:0=no,1=yes 1 yes
R:0=no,1=yes 1212 yes2yes2
R:2=two$0two  123  1two2two3 
R:2=two$0two 456 (empty)
R:2=two$0two,^.*$=$& 456 456