Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E1DE717BD7 for ; Mon, 6 Apr 2015 17:29:24 +0000 (UTC) Received: (qmail 15720 invoked by uid 500); 6 Apr 2015 17:29:15 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 15637 invoked by uid 500); 6 Apr 2015 17:29:15 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 15375 invoked by uid 99); 6 Apr 2015 17:29:15 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 17:29:15 +0000 Date: Mon, 6 Apr 2015 17:29:15 +0000 (UTC) From: "Benedikt Ritter (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (LANG-1033) Add StringUtils.countMatches(CharSequence, char) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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} > /** > *

Counts how many times the char appears in the given string.

> * > *

A {@code null} or empty ("") String input returns {@code 0}.

> * > *
>      * 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
>      * 
> * > * @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)