如何使用php解析**文件内的名称** .doc和.pdf文件

时间:2019-06-27 03:57:57

标签: php regex

如何使用php从.doc文件中解析名称

输入

'Satya S M Naidu Konathala                       Email: 2kssmln@gmail.com
Business Intelligence Analyst/Consultant                    Phone: +61-444 861 478


Work Profile:
1, National Australia Bank through Infosys Technologies, Melbourne                 Nov 2010 – till date        
2, Infosys Technologies, India                                     Oct 2005 – Oct 2010

Visa Status                                         : Australia Permanent Resident

Summary:
   Over 8 Years of experience in Oracle development, Data Warehouse report and ETL Development and BI Administrator
   Experienced with responsibilities of BI Design, Development, Testing and Supporting Data warehouse Database and Reporting.
   Experienced in Leading a Team of 10 containing Developers and Testers for Business Intelligence projects
   Experienced as BI Analyst with National Australia Bank and worked with senior Business managers and Architects in design and development of new BI Solutions
   Experienced in Building, maintaining and supporting Business Objects architecture in Development, Test and Production environments
   Developed solution for the deployment of reports and universes across environments, Lifecycle Management, producing auditing and usage stats and documented 
Name: Satya S M Naidu Konathala     Age:29'

预期输出为 Satya S M Naidu Konathala

  if (strpos($part, 'Name')||strpos($part, 'NAME')) {
     $pattern = '/[a-zA-Z.]+\.[a-zA-Z.]{0,2}/';
     preg_match_all($pattern, $part, $matches);
     foreach ($matches[0] as $match) {
        $records['Name'][] = $match;
     } 
  }    

1 个答案:

答案 0 :(得分:1)

设计正则表达式非常复杂。我很肯定应该有一些您可能想要查找和尝试的用于[doc / pdf]简历名称识别的软件包。否则,此任务将变得有些乏味。


我们可以在s模式下以类似于以下的表达式开始

([A-Z][a-z]+\s([A-Z]\.?\s?)?([A-Z]\.?\s?)?([A-Z][a-z]+)?\s?([A-Z][a-z]+)?)\s{2,}.*|[A-Z]{2,}\s.*?[A-Z]{2,}.*

Demo

测试

$re = '/([A-Z][a-z]+\s([A-Z]\.?\s?)?([A-Z]\.?\s?)?([A-Z][a-z]+)?\s?([A-Z][a-z]+))\s{2,}.*/s';
$str = '\'Satya S M Naidu Konathala                       Email: 2kssmln@gmail.com';

preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
var_dump($matches);