AI for M Patterns

53 views
Skip to first unread message

K.S. Bhaskar

unread,
Aug 26, 2025, 11:25:28 AMAug 26
to everyth...@googlegroups.com
We welcome Alex Woodhead to the YottaDB blog with his first guest post, on using AI for M Patterns, at https://yottadb.com/ai-for-m-patterns/. We hope you enjoy it. Please send comments our way.

Regards
- Bhaskar

--

Flávio Fornazier

unread,
Sep 17, 2025, 8:20:22 PM (6 days ago) Sep 17
to Everything MUMPS
Interesting! Reading above article made me think:

My data input field will set to Brazilian Portuguese currency format, i.e.,  "1.234.789,00", the maximum size will be 21 (including dots and comma).

I'm still asking myself: What would be the most optimized code to validate that data input using M Pattern Matching?

Any suggestion would be greatly appreciated

Thank you in advance.

  - Flavio -

K.S. Bhaskar

unread,
Sep 18, 2025, 4:42:24 PM (5 days ago) Sep 18
to Everything MUMPS
Why not try the tool and see what pattern it produces?

Regards
- Bhaskar

Maury Pepper

unread,
Sep 18, 2025, 5:34:12 PM (5 days ago) Sep 18
to Everything MUMPS
Well, first we need to know the rules for a valid input. For example, is 25 a valid input? Does it mean 25,00 or ,25? Is ,25 valid or do you require 0,25? Is 1234 valid or do you require 1.234? It is common to accept something without the cents and without the thousands separator, and then display the input in a standard format as you showed. Testing for the 21 character limit might be a test on the input or a test after your standard formatting.
  If x is the input, then you can test for the various valid inputs with something like  x?1(.21N,1.3N.(1"."3N)).1(1","2N)  This allows (up to 21 digits without dots or 1 to 3 digits followed by any number of groups of 1 dot and three digits) and then all of that can be followed by an optional one comma and two digits. Put a dot right after the ? to allow a comma without a leading digit. Tested with this immediate mode test loop:
     f  r !,"R$: ",x," " q:x=""  w $S($l(x)<22&(x?1(.21N,1.3N.(1"."3N)).1(1","2N)):"OK",1:"NG")

Flávio Fornazier

unread,
Sep 18, 2025, 6:00:25 PM (5 days ago) Sep 18
to Everything MUMPS
Mr. Maury,

Thank you for your explanation.

I have always worked reading one character at a time, i.e., R *X. This time I need to do it differently, but I've noticed reading your code that "M Pattern Matching" is more complex than I thought!

The data entry will already be formatted using dots  and the comma before being tested, i.e, 1.234.567,89

Regards.

Flávio Fornazier

unread,
Sep 18, 2025, 6:02:13 PM (5 days ago) Sep 18
to Everything MUMPS
Mr. Bhaskar,

Thank you for your reply. I'll try the tool after that.

Regards.

Em quinta-feira, 18 de setembro de 2025 às 17:42:24 UTC-3, K.S. Bhaskar escreveu:
Reply all
Reply to author
Forward
0 new messages