commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (LANG-1033) Add StringUtils.countMatches(CharSequence, char)
Date Mon, 06 Apr 2015 17:29:15 GMT

     [ https://issues.apache.org/jira/browse/LANG-1033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Benedikt Ritter closed LANG-1033.
---------------------------------

> Add StringUtils.countMatches(CharSequence, char)
> ------------------------------------------------
>
>                 Key: LANG-1033
>                 URL: https://issues.apache.org/jira/browse/LANG-1033
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>         Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
> Maven home: C:\Java\apache-maven-3.2.2
> Java version: 1.7.0_60, vendor: Oracle Corporation
> Java home: C:\Program Files\Java\jdk1.7.0_60\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>             Fix For: 3.4
>
>
> Add:
> {code:java}
>     /**
>      * <p>Counts how many times the char appears in the given string.</p>
>      *
>      * <p>A {@code null} or empty ("") String input returns {@code 0}.</p>
>      *
>      * <pre>
>      * StringUtils.countMatches(null, *)       = 0
>      * StringUtils.countMatches("", *)         = 0
>      * StringUtils.countMatches("abba", 0)  = 0
>      * StringUtils.countMatches("abba", 'a')   = 2
>      * StringUtils.countMatches("abba", 'b')  = 2
>      * StringUtils.countMatches("abba", 'x') = 0
>      * </pre>
>      *
>      * @param str  the CharSequence to check, may be null
>      * @param ch  the char to count
>      * @return the number of occurrences, 0 if the CharSequence is {@code null}
>      * @since 3.4
>      */
>     public static int countMatches(final CharSequence str, final char ch) ...
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message