Skip to end of banner
Go to start of banner

matchReplace

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8? Click here and leave these dusty old pages behind!

Availability

This routine is available starting with SIL Engine™ 4.8.0.13.

Syntax

matchReplace(source, target, replacement);

Description

Uses a regex expression to find and replace text within a string.

Parameters

Parameter name

Type

Required

Description

SourceStringYesText string to be updated.
TargetStringYesRegex expression used to target text for replacement.
ReplacementStringYesReplacement text used to update the target text found by the regex expression.

Return type

String

Example 1

string sourceText = "Oh, you are a Nigerian prince? Here is my credit card number 1111-2222-3333-4444.";

matchReplace(sourceText, "\d{4}-?\d{4}-?\d{4}-?\d{4}", "XXXX-XXXX-XXXX-XXXX");

Returns: "Oh, you are a Nigerian prince? Here is my credit card number XXXX-XXXX-XXXX-XXXX."

Example 2

Removes all HTML tags from a block of text.

string HTML = "<p>Geckos are a group of usually small, usually <strong style='color: blue;'>nocturnal</strong> lizards. They are found on every continent except Australia.</p>";
            
return matchReplace(HTML, "<[^>]*>", "");

Returns: Geckos are a group of usually small, usually nocturnal lizards. They are found on every continent except Australia.

See also

  • No labels