MATCH to Only Numbers

I have tried to use it in the following format:


But it does not work

The pattern you’re using matches 1-digit unsigned numbers only. Probably, you need in




if numbers can have a sign.

1 Like

Define “does not work” ?

Why not just use

IF NUMERIC(CLI:inscricao)



I think that depends on how many digits there are in the string.

This fails (returns true):


This works, with one less digit (returns false):


NUMERIC is nothing else as the call to the C Library function strtod() with the parameter converted from STRING to CSTRING. The buffer to hold converted CSTRING value is the 40 characters long including terminating 0-character.

1 Like

Unlike Numeric() with Match() I think trailing spaces matter, so if you want to allow spaces on the end you must Clip().

Your use of the $ modifier to match to the end would indicate you want all numbers with No trailing spaces, so this probably does not apply here, just thought I would mention it.

Asterisk * would allow [+-] to occur Zero or More times +-+1234

You probably want Question Mark ? that allows Zero or ONE + - … so ^[+-]?

For ClarionMag I had an article on MATCH and STRPOS with a small simple Match Tester tool that let you test a RegEx expression against 4 different test strings. It helps figure out the right code without compiling.

@vitesse always seems to find stuff on ClarionMag when I cannot. Next week I’ll find it and post it on GitHub.

ask and ye shall receive :grinning:

Using MATCH In Filters and Regular Expressions
by Carl Barnes
Published 2001-07-03

attached with thanks to Dave Harms as always.

cmag-2001-07.pdf (1.0 MB) (4.3 KB)

1 Like

Thanks Geoff!

Screen captures of the Match and StrPos tests to show how 1 expression can be tested against 5 test strings. I think I have a newer version with both on one window I can find next week.