I need to search various texts in Italian. These texts may be produced by any number of unknown different authors using slightly different conventions. I need to pull out as many of the telephone or fax numbers as possible with as low a rate of false positives as possible (I'd rather pick out 1 of 10 numbers accurately than get 11 out of 10 if you follow). The format of the numbers is variable. Unlike the north american (000) 000-0000 format, telephone and fax numbers in Italy can be anywhere from 3 to 15+ digits in length. Numbers can include .'s, spaces, /'s, -'s and ()'s and may be preceded by a space or a +

here are *some* examples of commonly used telephone number formats with their contexts:

poliambulatorio 050/701901
Tel. +39 0422 519111
Fax +39 0422 969501
Phone: +39.087105891
Fax: +39.0871562496
(+39) 06 6783933
(+39) 06 678793
Tel: 0668136061
Phone 39-0445-575870 Fax 39-0445-575399
P.I. 02212120246
Telefono 091.545606

these are the constraints that I have come up with so far, the problem is that it's a little too constraining and I'm not getting any results at all.

m/ ( numer ( i (tel|utili|verdi|facsimili|fax) |o (verde|tel|facsimile|fax|tel) ) |t: |f: |fax |al\snumero |phone |p.i. ) [^\d]{,7} (\d\s*){3,15} ([^\d]|$) /gx
Thanks for your help. Thanks especially to LAI for helping me make this question a tad less silly.

'share and enjoy'


In reply to regexp quandry by Ella

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.