Using regular expressions for searching SMAT
When using a regular expression to search for a particular message in SMAT, pay special attention to NL/CR.
The default search is case-insensitive.
The dot (.) matches all characters except line break characters, so ".*" only matchs to the end of a line. At that time, you can use "?s". The dot implies the line separators.
For example:
MSH:;~\&:HBOX:E:PCM:E:201208301315::ORU;R01;41:4299886:D:2.2:4299886: <CR>
PID::01969187:01322089;;;E:"":TEST;BABY;BOY;"":"":20110105:M::7:250 FEDERAL PALZA;""; <CR>
OBR:1:0000002159E30015;HBOX:0000002159E30015;HBOX:30015;ABDOMEN SINGLE VIEW/KUB;RDE: <CR>
NTE:1:L:"" <CR>
OBX:1:ST:Exam32Room94;Exam Room:1:RM 3:::"":::: <CR>
When the content you search does not cross NL/CR, you can search the message
that has both ORU
and 2.2
in the body. To do this, use: ORU.*2\.2
.
When the content you search goes across NL/CR, you can search the message that
has both ORU
and OBR
. To do this, use: (?s)ORU.*OBR
.
To search the message that has both ORU
and
Exam
, use: (?s)ORU.*Exam
.
(.*\s)*
or (.*\r)*
. There is a JDK
bug where the matcher stays in an infinite loop and never returns the result.
Multi-line search
The SMAT regular expression search yields results if the pattern matches in one line.
For example, the search for MSH.*PID
returns
all HL7 messages containing both an MSH
and PID
segment. The search always returns no messages.
In this example, use (?s)MSH.*PID
to use a
regular expression to do a multi-line search .
The "s
" flag makes the dot match any characters, including a line
terminator.