Navigate back to the homepage

React Native Regex

Infinitbility
React Native
July 10th, 2021 · 1 min read
React Native Regex

Hello Friends,

Welcome To Infinitbility!

Sometimes, we need regex to validate user details like some patterns for example Email validation, phone number validation and many things.

Now, we are going to use regex in react native email validation.

Let’s start today article React Native Regex

What is regex

What is regex?

A regular expression is a sequence of characters that specifies a search pattern. Usually such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings, or for input validation.

React Native Regex example

React Native codebase same to javascript then syntax are same for both, we have to write and regex in veriable and use javascript test functionalities to validate.

For now we are going to validate email using regex.

1validateEmail = (email) => {
2 const emailRegex = /^[\w-\.][email protected]([\w-]+\.)+[\w-]{2,4}$/;
3
4 if(emailRegex.test(email)){
5 return true;
6 }else{
7 return false;
8 }
9}

On above code we create validateEmail function to validate email using regex.

Subscribe Our Newsletter You will get monthly free programming book

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Subscribe Our Newsletter You will get monthly free programming book

Tutorials

React Native

Categories

More articles from Infinitbility

React Native Multiple Styles Example

React Native Multiple Styles Example

how to add multiple styles in react native

July 9th, 2021 · 1 min read
How to export excel in react

How to export excel in react

React export excel example

July 6th, 2021 · 1 min read
© 2020–2021 Infinitbility
Disclaimer
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]