Navigate back to the homepage

React Native Regex

React Native
July 10th, 2021 · 1 min read

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}$/;
4 if(emailRegex.test(email)){
5 return true;
6 }else{
7 return false;
8 }

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

Thanks for reading…

Follow me on Twitter

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.

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]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide



More articles from Infinitbility

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

React export excel example

July 6th, 2021 · 1 min read
© 2020–2022 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]