Regex & Validations in Android

Regular Expression or Regex is a very important expression matcher for applying validations in any android application. You can learn Regex. It is very easy to learn or you can find some combinations (or expressions) online for Email or password verification and much more. If you still find it difficult to create a Regex you can take some help from online tools or just mention your issue in Comment Box and I will solve it ASAP.

You can Watch my Video Tutorial or follow Steps Below:

What validations and Regex we are going to use: 

  1. The full name can contain Lowercase and Uppercase letters and also blank spaces.
  2. Email Address Validation through a regex.
  3. Mobile number should be at least 10 digits in length.
  4. Password validation through regex containing lowercase, uppercase, numbers, and special characters.

To design a simple sign up page create an activity and go to layout file activitymain.xml and paste the code below.



Also, add these lines to app gradle file:


Now Create a Java Class and paste the following code:



Now Go to and write the following code:





  1. You learned how to perform validation via creating another class or for simple validation click here.
  2. You learned the easiest way to implement regex to match patterns to apply validations in android.
  3. Using TextInputLayout to display errors. Learn to Design a Login Page here or learn using font awesome in android here.


How useful was this post?

Do not forget to rate! this helps us to Improve.

Average rating / 5. Vote count:

Read More Like This..

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!


Safiya Akhtar

Safiya Akhtar is Android Application Developer in India. She is currently working as a public consultant for career and education too, besides blogging and freelancing. She believes that it is never too late or too early to start what you have always dreamed of.

Your Views And Question are Welcome Here!