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

Cut out middle part of a String

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.2
    • 2.5
    • lang.*
    • None

    Description

      It would be handy to have a String method that cuts out the middle part of a String such that as much as possible is kept from the start and end of the String, but the middle part is replaced by an ellipsis "..."

      BeOS had a function like this, but it's poorly documented, missing examples:
      http://www.beunited.org/bebook/The%20Support%20Kit/String.html#Truncate()

      e.g.:
      A very long text with unimportant stuff in the middle but interesting start and end to see if the text is complete.
      becomes:
      A very long text...to see if the text is complete.

      Attachments

        1. LANG-405.diff
          3 kB
          Dave Meikle
        2. LANG-405.diff
          5 kB
          Henri Yandell
        3. LANG-405.diff
          4 kB
          Srihari Reddy

        Activity

          People

            Unassigned Unassigned
            grexe Gregor B. Rosenauer
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: