Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to check if a String is in valid format or not in Java8

I want to validate if a given String is in below format or not.

String validString = "Emp_idIn645745,48576845,8347683,8734682";

some of the invalid Strings are below:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • "EmpIdIn46374,49587,498576"
  • "Emp_Id=736437"

Will it be possible to achieve this in java 8?

>Solution :

If so, then it’s not a problem with Java 8. But it depends on what exact rules this string should contain. You will definitely have to build your own validator function.

I would start by checking the first part with <your-string>.startsWith("Emp_idIn").
For the numbers, you have to find your own way to validate them using your rules.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading