replace

Purpose

The function replace() is used to replace extracted results by a user-specified value.

Syntax

replace($group, target, replacement)

Arguments

The function takes three required arguments. The first argument $group is the argument to be formatted, the second argument target is its part (symbol, word or regular expression) to be replaced. The third argument replacement replaces the second one.

The function also accepts the following optional named parameters:

Named parameter

Comments

regex:=yes/no

switches on/off the use of regular expression

casesens:=yes/no

switches case sensitivity on/off

ignore_ws:=yes/no

ignores/forbids white spaces in a regular expression

Returned Value

A string value that was obtained by replacing the input value.

Examples

Dataset

XPDL-rule

Result

H1N1 virus

rule: r2

{

query: {phrase(0, char(alnum), virus)}:m

result: Match = $m

attribute: Influenza = replace($m, "virus", "influenza")

}

H1N1 influenza

H1N1 virus

rule: r1

{

query: {phrase(0, char(alnum), virus)}:m

result: Match = $m

attribute: Influenza = replace($m, ".*virus", "influenza", regex:=yes)

}

influenza

H1N1 virus

rule: r1

{

query: {phrase(0, char(alnum), virus)}:m

result: Match = $m

attribute: Influenza = replace($m, "1", "")

}

HN virus