Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 7.7.0
Div
Classe2e-refDiv

Otp
Floatingfalse

Rp
Rde

...

Trimming leading spaces
Code Block
languagenone
set trimmedString = stringSet.s1.replace("^[ ]+", "");
Trimming trailing spaces
Code Block
languagenone
set trimmedString = stringSet.s1.replace("[ ]+$", "");
Trimming leading and trailing spaces
Code Block
languagenone
set trimmedString = stringSet.s1.replace("^[ ]+|[ ]+$", "");
Trimming leading spaces and whitespaces (\t)
Code Block
languagenone
set trimmedString = stringSet.s1.replace("^[ \t]+", "");

Replacing Parts of a Regular Expression

If you want to replace parts of a string that contains a regular expression, you may run into the problem that the Runtime will interpret the matching part.
In this case, adorn the matching part expression with \Q and \E to mark it as a literal string, so the Runtime will simply take it as it is for comparison (see also Meta Characters).

Code Block
set pdfFilenamePattern = "invoice_\d{8}\d{6}\d{5}((\.pdf)|(\.PDF))";
set matchingPart       = "\d{8}\d{6}\d{5}";
set replacement        = "12345678_123456_12345";

set changed = replace(pdfFilenamePattern, concat('\Q', matchingPart, '\E'), replacement);

The same applies if the replacement contains a regular expression.