in reply to Re^2: Recognizing 3 and 4 digit number
in thread Recognizing 3 and 4 digit number

Wah! I guess I got excited and answered before noticing that we wanted to disqualify things that look like phone numbers. Sorry.

This isn't tested:

m/(?<![\d-])(\d{3,4})(?![\d-])/

But it would run afoul of phone numbers using commas to separate, or wrapping parens around area codes.

It might be useful to take a first pass and keep a list of offsets for "numbers" that should be ignored. It's probably easier to match a phone number with existing libraries than to match a 3 or 4 digit number that is not part of a phone number. In other words, on first pass, identify phone numbers, IP addresses, and other problematic numbers, and push their offsets and lengths into an array. Then on second pass disqualify any number that falls within one of the offset/length sets.


Dave