jaw mar jaw mar - 5 months ago 10
Java Question

Java multiple Regex Validation

I'm new to java and I'm trying to validate user input using a regex.

I need to validate two patterns :


  • version

  • version-1.xy when x & y are digits



below is my pattern but somehow it is not working..

String versionRegex = "^version-1.[1-9][1-9]|version";


Thanks for your help guys.

Answer

This will support version / version-1.xy / VERSION / VERSION-1.xy

String versionRegex  = "(?i)^version(-1\\.[1-9][1-9])?";
Comments