× 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.



John Y, you are quite correct - I should have specified {2,3} i.e. with the curly brackets.

John McKay

On 20/01/2012 22:36, John Yeung wrote:
On Fri, Jan 20, 2012 at 4:41 PM, John McKay<jmckay@xxxxxxxxxxxxxxxx> wrote:
I would use

\d(2,3)\W\d(2,3)\W\d(2,3)

\d(2,3) looks for either 2 or 3 digits.
\W looks for a single non-alphanumeric character, i.e.
your separator.
Interesting phone number. That's not a U.S. or Canadian phone number,
though. ;)

When parsing data, there is always the issue of how permissive you
want to be. If the whole point is to only pick out *exactly
formatted* data, then "single non-alphanumeric" is not necessarily as
good as the specific separator you are looking for. If the point is
to be a little flexible, then you may want to allow separators that
are anywhere from zero to two characters (like a right-paren and a
space, for example, if you're looking for phone numbers including an
area code).

This is from the RPG manual and is also on rpglanguage.com
To echo Scott's advice: Use the documentation for your specific regex
implementation, if possible. There are a number of similar but
not-quite-compatible regex "languages". I'm used to {m,n} for
denoting minimum of m, maximum of n occurrences (that is, curly braces
instead of parens).

John Y.


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.