Module watamebot

Class StringUtils

java.lang.Object
net.foxgenesis.util.StringUtils

public final class StringUtils extends Object
Utility class for Strings
Author:
Ashley
  • Field Details

    • PATTERN_URL

      public static final Pattern PATTERN_URL
      Compiled regex checking for URL character sequences. This pattern is case insensitive.
      \b((http|https|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|])
    • PATTERN_URL_WITH_GROUPING

      public static final Pattern PATTERN_URL_WITH_GROUPING
      Compiled regex checking for URL character sequences. This pattern is case insensitive and contains named groups for protocol, domain and path.
      \b(?<protocol>http|https|ftp|file)://(?<domain>[-a-zA-Z0-9+&@#%?=~_|!:,.;]*[-a-zA-Z0-9+&@#%=~_|])(?<path>\S*)
    • CONTAINS_URL

      public static final Predicate<String> CONTAINS_URL
      NEED_JAVADOC
  • Constructor Details

    • StringUtils

      public StringUtils()
  • Method Details

    • findURLWithGroups

      public static Stream<MatchResult> findURLWithGroups(@Nonnull String str)
      Find all URLs within a String and split its components into groups.
      Parameters:
      str - - String to check
      Returns:
      A Stream of MatchResults containing URL groups: protocol(1), domain(2) and path(3)
    • limit

      public static String limit(String str, int length)