Related Pages:
The Bridge uses the ICU's Regular Expressions package to compute regular expressions.

This appendix is divided into three parts:

The character \ (backslash) has a special meaning for EAL (Bridge Action Language) strings and regular expressions (RE). In EAL strings, it is used to escape single quotes, double quotes and itself. In REs, it is used to escape special characters and also itself. This double function of backslashes leads to three exceptions from the intuitive usage of backslashes if EAL literals are used to define a RE pattern that contains the same escape sequences as used in EAL literals.

The exceptions are:

if RE =  \  \  then  EAL literal = \  \  \  \
if RE =  \ "  then  EAL literal = \  \  \  "
if RE =  \ '  then  EAL literal = \  \ \  '

In all other cases, the EAL literal equals the RE.

For example, the following EAL statement replaces all occurrences of  \ by x. To match a \ in a RE we need the expression \ \. If we use an EAL literal, we need to escape each backslash again, getting:

set changed = aString.replace("\\\\", "x");
  • No labels