× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Tue, Jun 25, 2013 at 9:20 AM, Buzz Fenner <bfenner@xxxxxxxxxxxxxxxx> wrote:
I have a 20-character field (bank account) that needs to only contain blanks
or digits. In addition, the digits must be contiguous and right aligned.
Some examples are:

'12345678901234567890' (good)
' 67890' (good)
' #67890' (not good)
' 56789 ' (not good)

This is what I'm using for the pattern: '^[ ]*[0-9]+$'. I've also tried
coding it this way: '^\s*\d+$'. It works, mostly, but doesn't flag the last
example as a bad string. I would have thought the end-of-string anchor would
flag the string as bad, unless it stops checking after the digit '9' thereby
ignoring the space in the last position of the string.

Your regex patterns look OK to me. I'm not too familiar with Scott's
(or any other) regex in RPG, but if trailing spaces are being ignored,
it's possible that your input is automatically being trimmed. If
that's the case, then the easiest thing to do is to just work around
it (such as checking the right-trimmed length yourself, or checking
whether the last character is a space, etc.).

Trying to ensure you don't get bitten by automatic trimming is not
really worth it, but you could achieve it by adding a sentinel
character at the end yourself, like 'x', and checking the resulting
21-character field with the regex pattern '^[ ]*[0-9]+x$'.

John

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.