CharSequence
against all the patterns. It simplifies the usage of several regex expressions against the same input.RegexCollection collection = new RegexCollection(); collection.addPattern("number", "\\d+"); collection.addPattern("letters", "[A-Za-z]+"); RegexMatcher matcher = collection.matcher("156"); String name = matcher.getPatternName(); // return "number" boolean matches = matcher.matches(); // return true matcher = collection.matcher("Slayer"); name = matcher.getPatternName(); // return "letters" matches = matcher.matches(); // return true matcher = collection.matcher("1349 band"); name = matcher.getPatternName(); // return "letters" matches = matcher.matches(); // return false
Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences