Advertisement
vallec

RegexTester.class

Jan 10th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5.  
  6. public class RegexTester {
  7. public static List<Boolean> test(Regex regex, String[] strings) {
  8. Pattern pattern = Pattern.compile(regex.getPattern());
  9.  
  10. List<Boolean> matches = new ArrayList<Boolean>();
  11. for (String temp : strings) {
  12. Matcher matcher = pattern.matcher(temp);
  13.  
  14. if(matcher.matches()) {
  15. matches.add(true);
  16. } else {
  17. matches.add(false);
  18. }
  19. }
  20.  
  21. return matches;
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement