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

[lang] adding a StringUtils.replace method that takes an array or List of replacement strings

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.4
    • lang.*
    • None
    • Operating System: other
      Platform: Other

    • 36584

    Description

      I have the situation where I have a String template with a dozen replacements
      I need to make. When I loop through and use StringUtils.replace each time, it
      has to make a StringBuffer of the whole template each time. I think we could
      make this more efficient if we had a replace() method which took an array of
      Strings to search for, and an array of Strings to replace with (or we could
      use a Collection or List or something). This way we could possibly do the
      replace in one StringBuffer result.

      One issue is if the replacement text has Strings to be replaced, do we iterate
      through again until there are no Strings to search for? Based on your
      replaceChars(String str, String searchChars, String replaceChars) method, I
      assume the answer is no, but we could have a boolean flag to have it both ways.

      I can write this for you if you are interested, please let me know.

      Thanks!
      Chris

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--StringUtilsAndText.java
          18 kB
          Chris
        2. LANG-180.patch
          18 kB
          Henri Yandell
        3. LANG-180.patch
          16 kB
          Henri Yandell

        Activity

          People

            Unassigned Unassigned
            mchyzer@yahoo.com Chris
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: