› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › SMAT regular expression compound search
What Operating System and Cloverleaf Version are you using?
Are you sure this worked before? I don’t see how.
Your regular expression says look for a pipe (|) followed by ORM. Since ORM is the fist three characters of the segment there should be no pipe (|) before it, just a CR. It seems to me your expression would be something like:
rORM.*|NW|
Of course there are better, more explicit, regular expressions you could use
Don’t take this as gospel. I haven’t tested any of this just looking at the regexp.
I did a test on 5.7 and 6.1. The expression worked in 5.7 but not in 6.1. Maybe I should test some of the other expressions that I routinely use.
Keith – We are running cloverleaf 6.0 on an AIX server. And as you observed on your second post this worked in 5.7 but not on 6.0 and apparently 6.1 for you which we will move to this summer.
Charlie – The ORM I am looking for is in MSH-9 and the NW is ORC-2. This was just a simple example of a compound regex search I use a lot. It is a simple way to look for all records with MSH-9 = ORM AND ORC-2 = NW. I can do a single search for either component just fine. I can’t find a combination to do more than one.
This is not an earth-shaking change but it is a functionality that I used a lot and was really helpful. Am I missing another way to do this SMAT search in 6.0?
Thanks for any input!
Can you try this? |ORM(.|r)*|NW|.
I see that in 6.X you can add in multiple lines of criteria, however when using something like
Regular Expression
Include
Expression |ORM^O01
Expression |NW|
It gets treated as an ‘OR’ condition
It doesn’t appear to round the bend very well past r segment termination characters….I am guessing….That could be a problem…
David – It appears your option works. In a quick and limited test I found 139 ORM records in a SMAT file.
I searched with:
|ORM(.|r)*|NW| and got 50 records.
|ORM(.|r)*|XO| and got 89 records.
I’ll try it further and spend some time analyzing the syntax to understand the change.
Thanks for the tip. This may seem like a small issue but I didn’t realize how much I used it till it didn’t work anymore.
Thanks again to Keith, Charlie and David for the replies!!!!!!
we’re on 5.8.5 and I do compound searches occasionally.
Frankly, if I had to do several compound, I just converted the SMAT file at the command line and used grep or awk for my searches.
I just ran a quick test.
On CL 5.7 (Windows Server 2003) search on SMAT file with 600 messages:
|MDM.*|OPN| – runs in 2 seconds – gives 94 messages
|MDM(.|r)*|OPN| – runs in 22 seconds – gives the same 94 messages
On CL 6.1 (Windows Server 2008 R2) search on the same SMAT file:
|MDM.*|OPN| – immediatly says no messages found
|MDM(.|r)*|OPN| – as I am writing this the search already goes for 10+ minutes and the CL GUI is non-responsive anymore. Have to kill it through the task manager
Try this:
(?s)|MDM.*|OPN|
David,
That worked! And very fast!
Thanks a lot!
Sergey
Someone should make a bug fix request for this. It looks like in older versions of Cloverleaf (maybe pre-5.8) dot would match the CR character, and now it doesn’t. There’s some information about how to enable that here:
<a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#DOTALL” class=”bbcode_url”>http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#DOTALL
I opened a ticket with Infor and got the reply below:
Please see below from development…
We changed to use java build-in regular expression since 6.0 I.
In the build-in regular expression, this dot does not match line terminators by default.
Please advice user try with
(?s)|ORM.*|XO| (same as a user posted above)
I’ll ask if this is listed as a bugfix.
Max
Yeah, they should be able to change the default setting.
I get the above searches are basically searching SMAT for item 1 and item 2. Is there a way to do a single search of SMAT for item 1 OR item 2?
Example: Blood.*201 would return records that state Blood and also have the number 201 in each record.
What would I type if I wanted to return records that have Blood OR records that have 201?
So say I have 10 records and 2 say Blood and 3 other records say 201. I want a single query that will return the 2 records that say Blood and the 3 records that say 201 for a total of 5 results.
Thanks!
Blood|201
I didn’t test it though
Blood|201
I didn’t test it though
Thanks! That worked.
For those who do not know this expression to work around the change to Cloverleaf’s regex when searching multiline strings (like HL7 messages):
(?s) – this tells the regex parser to run with effective flag: s
Where the s modifier means Dot expression matches newline characters.
Here’s a really good online tool I use to test complex regular expressions: regex101.com
FYI – I tried replicating this issue on our updated engine (v6.1.3 on WinServer 2012) against HL7 messages stored in encrypted SMATDB. The search was ‘|ORU.*|RP|’ and it worked as expected. I tried many permutations and never needed to add the (?s) flag to work around the issue. 🙂