Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1033

Add StringUtils.countMatches(CharSequence, char)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.4
    • lang.*
    • None

    Description

      Add:

          /**
           * <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) ...
      

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: