Menu

PREFIX statement

Rx (9)
Oleg Osepyants

PREFIX statement

This statement adds the specified string before the beginning of the text or text fragment.

Usage

PREFIX <Value>
PREFIX <Value> INSIDE OF <ContextArea>
PREFIX <Value> OUTSIDE OF <ContextArea>

Parameters

  • Value - An Rx string that is added to the beginning of the text. This parameter must not be a regular expression (otherwise you will get an error).
  • ContextArea - An Rx string that specifies the Context area (not needed if the statement is running in the global scope).

Examples

Example 1

To get started, just adding the "Hello!!!" at the beginning of text.

PREFIX P"Hello!!! "

Original text

Please tell me how to get to the post office.

The text after applying the statement above

Hello!!! Please tell me how to get to the post office.

Example 2

Adding the "*" at the beginning of each paragraph. To do this, we need to use the [Context areas]. Our context area will be the LF and CR characters. Anything outside of these areas will be treated as paragraphs.

PREFIX P"* " OUTSIDE OF B"\r\n"

Original text

Tomorrow the sun will rise again.
They say the weather will be fine tomorrow.
And we will go to the river.

The text after applying the statement above

* Tomorrow the sun will rise again.
* They say the weather will be fine tomorrow.
* And we will go to the river.

Related

Wiki: Context areas
Wiki: Rx text transformation script language

MongoDB Logo MongoDB