I'm looking for a Java library which can generate common regular expressions, such as:

  • numbers of n digits
  • alphanumeric sequences (no special chars)
  • URLs
  • email addresses
  • IP addresses
  • etc.

The generated pattern must be compatible with the java.util.regex API.

  • This sounds implausible. What would this hypothetical library generate the regexes from? An input language that is capable of expressing those things would be just as complicated as regexes. – Stephen C Oct 11 '14 at 23:56
  • 1
    @StephenC For example, compare HypotheticalLib.email() with Pattern.compile("^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"). – Paolo Fulgoni Oct 13 '14 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.