Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Set;
- import java.util.TreeSet;
- public class LoginCharLimiter {
- private final Set<Character> chars = new TreeSet<>();
- public LoginCharLimiter(String chars){
- for(char ch : chars.toCharArray()){
- this.chars.add(ch);
- }
- }
- public String handle(String str){
- String splited[] = str.split("[;:]", 2);
- if(splited.length != 2)
- return null;
- for(char ch : splited[0].toCharArray()){
- if(!this.chars.contains(ch))
- return null;
- }
- return str;
- }
- }
Add Comment
Please, Sign In to add comment