Skip to main content

Need Help Using Spok Knowledge?

Internet Explorer is not supported. Please reload in Chrome, Edge, Firefox, or Safari.
Spok

Creating Regular Expressions in Spok Messenger

Example 1

The following regular expression can be used to communicate information in PMSG implementations:

^(?<FI>.*)[:](?<UI>.*)[:](?<RI>.*)[:](?<BI>.*)[:](?<AlarmType>.*)[:](?<Msg>.*)[:](?<PID>.*)[:](?<LastName>.*)[:](?<FirstName>.*)

This extraction expression has the ability to communicate the facility identifier (FI), unit identifier (UI), room identifier (RI), bed identifier (BI), alarm type (AlarmType), message (Msg), patient identification number (PID), last name (LastName), and first name (FirstName) for the patient.

Below is a breakdown of the regular expression and what each component means to the expression.

^

^

Tells the expression to start at the beginning of the input. 

 

(?<FI>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<FI> 

Names the captured characters with a tag to be used later. In this case, the facility identifier information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<UI>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<UI> 

Names the captured characters with a tag to be used later. In this case, the unit identifier information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<RI>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<RI> 

Names the captured characters with a tag to be used later. In this case, the room identifier information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<BI>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<BI> 

Names the captured characters with a tag to be used later. In this case, the bed identifier information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<AlarmType>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<AlarmType> 

Names the captured characters with a tag to be used later. In this case, the alarm type information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<Msg>.*)

Starts capturing what we specify inside into a group.

?

The expression may or may not find this item. An example explanation can be found above. 

<Msg> 

Names the tag for the captured characters to be used later as part of the outgoing message for the event. In this case, the message information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

End the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<PID>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<PID> 

Names the captured characters with a tag to be used later. In this case, the patient identification number information is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<LastName>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<LastName> 

Names the captured characters with a tag to be used later. In this case, the last name information for the patient is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

(?<FirstName>.*)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<FirstName>

Names the captured characters with a tag to be used later. In this case, the first name information for the patient is included.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

Ends the specification and grouping capture.

 

Example 2

^(?<FI>\w+)[:](?<UI>\w+)[:](?<RI>\w+)[:](?<BI>\w+)\s(?<MS>.*)

This expression captures any input coming from a targeted input integration and passes that information into the Events interface for processing. Below is a breakdown of the regular expression and what each component means to the expression.

 

^

^

Tells the expression to start at the beginning of the input. 

 

(?<FI>\w+)

Opens a section to start capturing what is specified inside into a group. Multiple groupings can be used within a single expression, as shown above.

?

The expression may or may not find this item. For example, when the “?” symbol is used in front of “slh”, the system would recognize “slh:250:300:1 Assistance needed” as well as “:250:300:1 Assistance needed”. If the “?” symbol is not used in front of “slh”, the system would only recognize the full expression of “slh:250:300:1 Assistance needed” because “slh” is included in the expression. When the “?” is used, the system marks the “slh” as “optional.” Therefore allowing the system to recognize applicable expressions that do not necessarily included that exact information entered. 

<FI> 

Names the captured characters with a tag to be used later.

\w

Captures any alphanumeric character (this is the specification of the capture for the kind of data we are looking for, such as a character, number etc.).

+

Repeats the above capture an unlimited number of times.

)

Ends the specification and grouping capture.

(<FI>\w+) 

What the expression for the facility ID (FI) looks like when assembled.

 

[:]

[

Range begins.

:

What to extract (a colon in this case as a delimiter between fields).

Range ends.

[:]

What the range looks like when assembled. This means that we want to extract a range, but do not want to group it or tag it. 

 

\s

 

\s 

Looks for and extracts a white “space” character. If a “tab” white space is included in the input, a \t could be used.

 

 

(?<MS>.*)

Starts capturing what we specify inside into a group.

?

The expression may or may not find this item. An example explanation can be found above. 

<MS> 

Names the tag for the captured characters to be used later as part of the outgoing message for the event.

.*

The “dot Star” indicates a repeat of any character multiple times until the next boundary or next instruction is received.

)

End the specification and grouping capture.

(?<MS>.*)

What the expression for the message tag (MS) looks like when assembled.