commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Closed: (LANG-573) Add new APIs to StringUtils (countLowerCase, countUpperCase, countDigits)
Date Sat, 09 Jan 2010 12:16:54 GMT

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

Henri Yandell closed LANG-573.
------------------------------

    Resolution: Won't Fix

I think a better solution is to use regexps here:

    public static int countMatches(String text, String regex) {
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(text);
        int count = 0;
        while(m.find()) {
            count++;
        }
        return count;
    }

Closing as WONTFIX, though I've added the code above to LANG-397 as a possible add for a RegexUtils.

> Add new APIs to StringUtils (countLowerCase, countUpperCase, countDigits)
> -------------------------------------------------------------------------
>
>                 Key: LANG-573
>                 URL: https://issues.apache.org/jira/browse/LANG-573
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>            Reporter: Alvin Chee
>             Fix For: 3.0
>
>
> private static int countUpperCase(String s) {
> 	int cLen = s.length();
> 	int count = 0;
> 	for (int i = 0; i < cLen; i++) {
> 		if (Character.isUpperCase(s.charAt(i)))
> 			count++;
> 	}
> 	return count;
> }
> private static int countLowerCase(String s) {
> 	int cLen = s.length();
> 	int count = 0;
> 	for (int i = 0; i < cLen; i++) {
> 		if (Character.isLowerCase(s.charAt(i)))
> 			count++;
> 	}
> 	return count;
> }
> private static int countDigits(String s) {
> 	int cLen = s.length();
> 	int count = 0;
> 	for (int i = 0; i < cLen; i++) {
> 		if (Character.isDigit(s.charAt(i)))
> 			count++;
> 	}
> 	return count;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message