Class StringUtil

java.lang.Object
com.blamejared.crafttweaker.api.util.StringUtil

@ZenRegister public class StringUtil extends Object
Basic String utils exposed to ZenScript and for use in Java code.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • matchesRegex

      public static boolean matchesRegex(String string, String regex)
      Checks if the given string matches the given regular expression
      Parameters:
      string - String to check
      regex - Regex to check against
      Returns:
      True if the string matches. False otherwise
    • quoteAndEscape

      public static String quoteAndEscape(net.minecraft.resources.ResourceLocation location)
      Quotes the given ResourceLocation in double quotes (") and escapes any control character.
      Parameters:
      location - ResourceLocation to quote and escape.
      Returns:
      a new String with the ResourceLocation quoted and escaped.
    • quoteAndEscape

      public static String quoteAndEscape(String str)
      Quotes the given String in double quotes (") and escapes any control character.
      Parameters:
      str - String to quote and escape.
      Returns:
      a new String with the String quoted and escaped.
    • wrap

      public static String wrap(String str, String with, boolean escape)
      Wraps the given String in another String and also optionally escapes control characters in the String.
      Parameters:
      str - String to wrap
      with - String to wrap with
      escape - Should control characters be escaped
      Returns:
      a new String that is wrapped with the given String and optioanlly escaped.