Jump to content

Up to 6 Numbers followed by a letter

Go to solution Solved by kicken,

Recommended Posts


I have the following expression but it doesn't work as I wish it to...


I need any 6 numbers followed by an M.... however, it can be any 5 numbers followed by an M... for example

123456M = Valid
1234M = Valid

123445 = Invalid
RANDOM = Invalid


Link to comment
Share on other sites

  • Solution
3 hours ago, DanRz said:

The braces specify a repetition range, like so: {min[,max]}.  If you only set the min value then it is an exact count.

So what you have says match exactly 5 digits, no more and no less. Presumably, you'd want to instead match between 0 and 5 digits, assuming something like 8M is valid.  To do that, you set both values accordingly.



Link to comment
Share on other sites

Bonus fact: the default min value is 0 and the default max value is unbounded/infinity, so if you use that comma (to indicate it's not an {exact} count but a {min,max} range) then you can leave out the min value itself to get the same "up to X" count.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.