[
https://issues.apache.org/jira/browse/LANG-910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13801994#comment-13801994
]
Matt Benson commented on LANG-910:
----------------------------------
Followup: Your example suggested that a user looking for "kins" would
intuitively supply 2 as the final argument. Maybe so, but I think the
_correct_ behavior would really be:
Yes, support pulling in each matching subsequence, but rather than:
{code}
assertEquals("kins", StringUtils.substringMatching("two little pumpkins sitting
over there", Pattern.compile("(....) "), 2));
{code}
The correct assertion would be:
{code}
assertEquals("kins", StringUtils.substringsMatching("two little pumpkins
sitting over there", Pattern.compile("(....) "), 1)[1]);
{code}
Less intuitive perhaps, but IMO more defensible in terms of "why did we do it
this way?". We provide the required functionality but the path from
{{Pattern}}/{{Matcher}} APIs is fairly evident.
> Patch to extend StringUtils
> ---------------------------
>
> Key: LANG-910
> URL: https://issues.apache.org/jira/browse/LANG-910
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.*
> Affects Versions: 3.1
> Environment: Developed on Ubuntu 13.04 with openjdk 7u25
> Reporter: Timur Yarosh
> Labels: patch
> Fix For: 3.2, Discussion
>
> Attachments: LANG-910.patch,
> substring-matches-and-white-space-normalize.patch
>
>
> This patch extends StringUtils capabilities: added methods to find
> substring(s) by Pattern. Also method
> org.apache.commons.lang3.StringUtils#normalizeSpace now replaces ASCII #160
> char to normal whitespace.
--
This message was sent by Atlassian JIRA
(v6.1#6144)