Class Parser

java.lang.Object
org.schabi.newpipe.extractor.utils.Parser

public final class Parser extends Object
Avoid using regex !!!
  • Method Details

    • matchOrThrow

      @Nonnull public static Matcher matchOrThrow(@Nonnull Pattern pattern, String input) throws Parser.RegexException
      Throws:
      Parser.RegexException
    • matchGroup1

      @Nonnull public static String matchGroup1(String pattern, String input) throws Parser.RegexException
      Matches group 1 of the given pattern against the input and returns the matched group
      Parameters:
      pattern - The regex pattern to match.
      input - The input string to match against.
      Returns:
      The matching group as a string.
      Throws:
      Parser.RegexException - If the pattern does not match the input or if the group is not found.
    • matchGroup1

      @Nonnull public static String matchGroup1(Pattern pattern, String input) throws Parser.RegexException
      Matches group 1 of the given pattern against the input and returns the matched group
      Parameters:
      pattern - The regex pattern to match.
      input - The input string to match against.
      Returns:
      The matching group as a string.
      Throws:
      Parser.RegexException - If the pattern does not match the input or if the group is not found.
    • matchGroup

      @Nonnull public static String matchGroup(String pattern, String input, int group) throws Parser.RegexException
      Matches the specified group of the given pattern against the input, and returns the matched group
      Parameters:
      pattern - The regex pattern to match.
      input - The input string to match against.
      group - The group number to retrieve (1-based index).
      Returns:
      The matching group as a string.
      Throws:
      Parser.RegexException - If the pattern does not match the input or if the group is not found.
    • matchGroup

      @Nonnull public static String matchGroup(@Nonnull Pattern pattern, String input, int group) throws Parser.RegexException
      Matches the specified group of the given pattern against the input, and returns the matched group
      Parameters:
      pattern - The regex pattern to match.
      input - The input string to match against.
      group - The group number to retrieve (1-based index).
      Returns:
      The matching group as a string.
      Throws:
      Parser.RegexException - If the pattern does not match the input or if the group is not found.
    • matchGroup1MultiplePatterns

      public static String matchGroup1MultiplePatterns(Pattern[] patterns, String input) throws Parser.RegexException
      Matches multiple patterns against the input string and returns the first successful matcher
      Parameters:
      patterns - The array of regex patterns to match.
      input - The input string to match against.
      Returns:
      A Matcher for the first successful match.
      Throws:
      Parser.RegexException - If no patterns match the input or if patterns is empty.
    • matchMultiplePatterns

      public static Matcher matchMultiplePatterns(Pattern[] patterns, String input) throws Parser.RegexException
      Matches multiple patterns against the input string and returns the first successful matcher
      Parameters:
      patterns - The array of regex patterns to match.
      input - The input string to match against.
      Returns:
      A Matcher for the first successful match.
      Throws:
      Parser.RegexException - If no patterns match the input or if patterns is empty.
    • isMatch

      public static boolean isMatch(String pattern, String input)
    • isMatch

      public static boolean isMatch(@Nonnull Pattern pattern, String input)
    • compatParseMap

      @Nonnull public static Map<String,String> compatParseMap(@Nonnull String input)