danbettles/telex

v0.0.0-alpha.4 2022-04-23 07:50 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:04 UTC


README

Telex 在文本中查找电话号码。

由于之前编写了一段处理欧洲电话号码的极其不灵活的代码,我想看看是否可以编写一段相对简单 - 而且稍微更优雅 - 的代码来检测 任何 电话号码,具有一定的精确度。 Telex 的确比之前的解决方案更优雅,也可能更有用,但它仍然远非完美 - 我认为它仍然过于天真。这是一个有趣的挑战,我们期待您的反馈 - 感谢。

Telex 被用于 SeeTheWorld

使用方法

目前

use DanBettles\Telex\Telex;
use DanBettles\Telex\NumberFinder;
use DanBettles\Telex\CountryTelephoneNumberMatcherFactory;

$telex = new Telex(new NumberFinder(), new CountryTelephoneNumberMatcherFactory());
$matches = $telex->findAll('A UK landline number: (01234) 567 890.  A UK mobile number: +44 (0)7123 456 789.');

待办事项

  • 在可行的情况下,为区号和结构良好的本地号码编码模式,以增加匹配器的精确度。
  • 编写更多测试,特别是针对 Telex
  • 处理多个相邻号码。
  • 向 Telex 中的查找方法添加日志记录,以便更容易识别不匹配的原因。