Tiago Ribeiro · Oct 18, 2018

$match or "?"

Hello all...

Is there two matching patterns in Caché, is there a difference in use one or the other?

USER>set a = "(1234)"

Using $match.

USER>w $match(a,"\([0-9]{4}\)")


Using literal match (sorry if not correctly term expression)

USER>W a?1"("4n1")"


What is different from using one or the other?

The 'a?1"("4n1")"' does this pattern exist only Caché.
Exists performance improvement with use pattern Caché?

0 483
Discussion (2)3
Log in or sign up to continue

Hi Tiago,

The ? pattern match is native to COS and has been in the product since day 1. You will also find it in GT.m and a few other fringe M systems, but probably nowhere else.

The $match feature was introduced back in 2012. It uses an external Regex library called ICU.

Both are highly optimised for general use cases (millions of operations per second).

The ? pattern matching syntax is less expressive than Regex, but this also makes it easy to learn and remember.

Regex would be the better choice for more complex pattern matching requirements.