Skip to content

Regex patterns for Suffix and Title need updating #14

Description

@groggu

This is good little parser, but trying it with php 7 I found that the Title and Suffix expressions no longer work as expected. The space between them and the name was not being detected in the pattern so names like "Frank Tester" were becoming "ank Tester"

Here's the update to those patterns. I will try to come back later and do a proper pull request, but for now, here's the update needed in Parse.php

         $nicknamesRegex
             = "/ ('|\"|\(\"*'*)(.+?)('|\"|\"*'*\)) /"; // names that starts or end w/ an apostrophe break this
 
-        $titleRegex = "/^($titles)/";
-        $suffixRegex = "/,* *($suffixes)$/";
+        $titleRegex = "/^($titles)\s+/";
+        $suffixRegex = "/\,?\s+($suffixes)$/";
         $lastRegex = "/(?!^)\b([^ ]+ y |$prefixes)*[^ ]+$/";
         $leadingInitRegex = "/^(.\.*)(?= \p{L}{2})/"; // note the lookahead, which isn't returned or replaced
         $firstRegex = "/^[^ ]+/"; //

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions