Repository: commons-text
Updated Branches:
  refs/heads/master 6fd10f89a -> 7de03831b


TEXT-20: Update salutations regex as per comments in pull request


Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/7de03831
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/7de03831
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/7de03831

Branch: refs/heads/master
Commit: 7de03831b805f795041ce4f13d53a6330cd64904
Parents: 6fd10f8
Author: Bruno P. Kinoshita <brunodepau...@yahoo.com.br>
Authored: Sun Nov 20 20:43:25 2016 +1300
Committer: Bruno P. Kinoshita <brunodepau...@yahoo.com.br>
Committed: Sun Nov 20 20:43:25 2016 +1300

----------------------------------------------------------------------
 src/main/java/org/apache/commons/text/names/HumanNameParser.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-text/blob/7de03831/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 1348313..5f4fa20 100644
--- a/src/main/java/org/apache/commons/text/names/HumanNameParser.java
+++ b/src/main/java/org/apache/commons/text/names/HumanNameParser.java
@@ -146,7 +146,7 @@ public final class HumanNameParser {
         // TODO compile regexes only once when the parser is created
         final String suffixes = StringUtils.join(this.suffixes, "\\.*|") + 
"\\.*";
         final String prefixes = StringUtils.join(this.prefixes, " |") + " ";
-        final String salutations = StringUtils.join(this.salutations, " |") + 
" ";
+        final String salutations = StringUtils.join(this.salutations, " |");
 
         // The regex use is a bit tricky.  *Everything* matched by the regex 
will be replaced,
         // but you can select a particular parenthesized submatch to be 
returned.
@@ -155,7 +155,7 @@ public final class HumanNameParser {
         final String nicknamesRegex = "(?i) 
('|\\\"|\\(\\\"*'*)(.+?)('|\\\"|\\\"*'*\\)) ";
         final String suffixRegex = "(?i),* *((" + suffixes + ")$)";
         final String lastRegex = "(?i)(?!^)\\b([^ ]+ y |" + prefixes + ")*[^ 
]+$";
-        final String salutationRegex = "^(?i)(("+salutations+")\\.)";
+        final String salutationRegex = "^(?i)(("+salutations+")(\\.|\\s))";
         // note the lookahead, which isn't returned or replaced
         final String leadingInitRegex = "(?i)(^(.\\.*)(?= \\p{L}{2}))";
         final String firstRegex = "(?i)^([^ ]+)";

Reply via email to