salutations: regex optionally looks for "."
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/ddafb1fc Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/ddafb1fc Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/ddafb1fc Branch: refs/heads/master Commit: ddafb1fc1f459de6d3b16c683793830549210699 Parents: 4bb5ddd Author: Tom MacKenzie <tom.s.macken...@gmail.com> Authored: Mon Jun 20 11:36:16 2016 -0500 Committer: Tom MacKenzie <tom.s.macken...@gmail.com> Committed: Mon Jun 20 11:36:16 2016 -0500 ---------------------------------------------------------------------- .../java/org/apache/commons/text/names/HumanNameParser.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-text/blob/ddafb1fc/src/main/java/org/apache/commons/text/names/HumanNameParser.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/names/HumanNameParser.java b/src/main/java/org/apache/commons/text/names/HumanNameParser.java index 84fe12a..fd1608a 100644 --- a/src/main/java/org/apache/commons/text/names/HumanNameParser.java +++ b/src/main/java/org/apache/commons/text/names/HumanNameParser.java @@ -110,8 +110,7 @@ public final class HumanNameParser { public HumanNameParser() { // TODO make this configurable this.salutations = Arrays.asList( - "mr", "mrs", "ms", "miss", "dr", - "mr.", "mrs.", "ms.", "miss.", "dr." + "mr", "mrs", "ms", "miss", "dr" ); this.suffixes = Arrays.asList( "esq", "esquire", "jr", @@ -144,7 +143,7 @@ public final class HumanNameParser { // but you can select a particular parenthesized submatch to be returned. // Also, note that each regex requres that the preceding ones have been run, and matches chopped out. // names that starts or end w/ an apostrophe break this - String salutationRegex = "^(?i)(("+salutations+"))"; + String salutationRegex = "^(?i)(("+salutations+")\\.)"; String nicknamesRegex = "(?i) ('|\\\"|\\(\\\"*'*)(.+?)('|\\\"|\\\"*'*\\)) "; String suffixRegex = "(?i),* *((" + suffixes + ")$)"; String lastRegex = "(?i)(?!^)\\b([^ ]+ y |" + prefixes + ")*[^ ]+$";