Advertisement
BanishMemory

StringSplitter regex

May 26th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. import java.util.regex.Pattern;
  2.  
  3. public class StringSplitter {
  4.     private Pattern spacesPattern;
  5.     private static final String REGEX_STRING = "\\s+";
  6.  
  7.     public StringSplitter() {
  8.         this.spacesPattern = Pattern.compile(REGEX_STRING);
  9.     }
  10.  
  11.     public String[] nonPrecompiledTest(String bigS) {
  12.         return bigS.split(REGEX_STRING);
  13.     }
  14.  
  15.     public String[] precompiledTest(String bigS) {
  16.         return this.spacesPattern.split(bigS);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement