package jpower.core.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Regular Expression Utilities
 */
public class RegularExpression
{
   /**
    * Creates a String Scanner
    *
    * @param str input string
    * @return string scanner
    */
   public static StringScanner scanner(String str)
   {
      return new StringScanner(str);
   }

   /**
    * Checks if a String Matches a Pattern
    * @param pattern pattern
    * @param input input string
    * @return true if it matches, otherwise false
    */
   public static boolean matches(Pattern pattern, String input)
   {
      return pattern.matcher(input).matches();
   }

   /**
    * Gets the Capture Groups for the pattern again the input
    * @param pattern pattern
    * @param input input string
    * @return array of capture groups
    */
   public static String[] captures(Pattern pattern, String input)
   {
      List<String> captures = new ArrayList<>();
      Matcher matcher = pattern.matcher(input);
      for (int i = 0; i < matcher.groupCount(); i++)
      {
         captures.add(matcher.group(i));
      }
      return captures.toArray(new String[captures.size()]);
   }

   /**
    * Gets the Capture Groups for the pattern again the input
    * @param pattern pattern
    * @param input input string
    * @return array of capture groups
    */
   public static String[] captures(String pattern, String input)
   {
      return captures(Pattern.compile(pattern), input);
   }
}

@@ -210,16 +210,426 @@
 ssion%0A%7B%0A
+%0A   private Pattern pattern;%0A%0A   /**%0A    * Constructs a new Regular Expression Wrapper%0A    * @param pattern pattern%0A    */%0A   public RegularExpression(Pattern pattern)%0A   %7B%0A      this.pattern = pattern;%0A   %7D%0A%0A   /**%0A    * Constructs a new Regular Expression Wrapper%0A    *%0A    * @param pattern pattern%0A    */%0A   public RegularExpression(String pattern)%0A   %7B%0A      this.pattern = Pattern.compile(pattern);%0A   %7D%0A%0A
    /**%0A 
@@ -1943,11 +1943,491 @@
 t);%0A   %7D
+%0A%0A   /**%0A    * Gets the Capture Groups for the pattern again the input%0A    *%0A    * @param input input string%0A    * @return array of capture groups%0A    */%0A   public String%5B%5D captures(String input)%0A   %7B%0A      return captures(pattern, input);%0A   %7D%0A%0A   /**%0A    * Checks if a String Matches the pattern%0A    *%0A    * @param input input string%0A    * @return true if it matches, otherwise false%0A    */%0A   public boolean matches(String input)%0A   %7B%0A      return matches(pattern, input);%0A   %7D
 %0A%7D%0A

Make RegularExpression have constructor and have instance utilities