Regex Curly brackets not working properly

Status
Not open for further replies.
B

Blame

Guest
I have the following problem:

I am working with openedge Progress-4gl, version 11.3. I am trying to use a regex to check if the entered string is valid according to our requirments.

The string should be exactly 6 characters long, with only numbers. So I came to this regex: [0-9]{6}. According to online regex testers it should work (I know it will also put strings that are longer than 6 characters as true, I just removed the extra characters to make it more clear what the problem is).

Now when I use this regex in progress, it is as if the {6} part is simply ignored/removed. so it will validate any string with a single number in it.

Full code:

DEFINE VARIABLE regexp AS CLASS System.Text.RegularExpressions.Regex NO-UNDO.
regexp = NEW System.Text.RegularExpressions.Regex("[0-9]{6}").


results:

regexp:IsMatch("123456") => returns true
regexp:IsMatch("123") => returns true
regexp:IsMatch("1") => returns true
regexp:IsMatch("") => returns false


Does anyone have experience with this kind of problem? I could solve it using following regex: [0-9][0-9][0-9][0-9][0-9][0-9], but that is just silly.

Thanks in advance :)

Continue reading...
 
Status
Not open for further replies.
Top