Package org

Class StringManipulationTools

java.lang.Object
org.StringManipulationTools
All Implemented Interfaces:
HelperClass

public class StringManipulationTools
extends Object
implements HelperClass
Author:
klukas
  • Field Details

  • Constructor Details

    • StringManipulationTools

      public StringManipulationTools()
  • Method Details

    • stringReplace

      public static String stringReplace​(String s, String find, String replace)
      Replace occurrences of a substring. http://ostermiller.org/utils/StringHelper.html StringHelper.replace("1-2-3", "-", "|");
      result: "1|2|3"
      StringHelper.replace("-1--2-", "-", "|");
      result: "|1||2|"
      StringHelper.replace("123", "", "|");
      result: "123"
      StringHelper.replace("1-2---3----4", "--", "|");
      result: "1-2|-3||4"
      StringHelper.replace("1-2---3----4", "--", "---");
      result: "1-2----3------4"
      Parameters:
      s - String to be modified.
      find - String to find.
      replace - String to replace.
      Returns:
      a string with all the occurrences of the string to find replaced.
      Throws:
      NullPointerException - if s is null.
    • removeHTMLtags

      public static String removeHTMLtags​(String textWithHtmlTags)
    • removeTags

      public static String removeTags​(String textWithHtmlTags, String tagA, String tagB)
    • removeTagsGetTextAndRemovedTexts

      public static ArrayList<String> removeTagsGetTextAndRemovedTexts​(String textWithHtmlTags, String tagA, String tagB)
      Removes the tags from a html-text and gives back the striped text.
      Parameters:
      textWithHtmlTags - the text with html tags
      tagA - The left tag (e.g. )
      tagB - The right tag (e.g. )
      Returns:
      The array list< string>, where get(0) is the striped text and all other are the striped texts
    • getWordWrap

      public static String getWordWrap​(String desc, int width)
    • getWordWrap

      public static String getWordWrap​(String[] desc, int width)
    • removeNumbersFromString

      public static String removeNumbersFromString​(String s)
    • getNumbersFromString

      public static String getNumbersFromString​(String s)
    • getAllNumbersFromString

      public static List<Integer> getAllNumbersFromString​(String str)
    • UnicodeToURLsyntax

      public static String UnicodeToURLsyntax​(String unicodeText)
    • UnicodeToHtml

      public static String UnicodeToHtml​(String unicodeText, HashSet<Character> badChars)
    • UnicodeToHtml

      public static String UnicodeToHtml​(String unicodeText)
    • htmlToUnicode

      public static String htmlToUnicode​(String html)
      Parameters:
      html -
      Returns:
    • htmlNamedEntities2Unicode

      public static String htmlNamedEntities2Unicode​(String html)
      converts all HTML named entities within a string to unicode
      Parameters:
      html -
      Returns:
      unicode string
    • getFileSystemName

      public static String getFileSystemName​(String name)
    • getStringList

      public static String getStringList​(ArrayList<?> elements, String div)
    • splitSafe

      public static String[] splitSafe​(String str, String delimiter)
    • reverse

      public static String reverse​(String in)