Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
What is the regex for url validation in react native?

URL validation checks if a given text is a URL or not. Such checks are often performed when a user has to enter a URL on a web form. To ensure that the entered text corresponds to a URL, I tried to implement the regex like this

regexurl = “((http|https)://)(www.)?” + “[a-zA-Z0-9@:%._\\+~#?&//=]{2,256}\\.[a-z]” + “{2,6}\\b([-a-zA-Z0-9@:%._\\+~#?&//=]*)”

But I am getting error, Please help where I am being wrong Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If your runtime supports it, the better way of validating URLs is using the URL constructor. You can then use the parsed object to verify parts of it separately. For example, to check if something is a valid HTTP(s) URL:

function isValidHttpUrl(s) {
  let url;
  try {
    url = new URL(s);
  } catch (e) { return false; }
  return /https?/.test(url.protocol);
}

isValidHttpUrl("banana"); // false, not a URL
isValidHttpUrl("http://example.com"); // true, is an HTTP URL
isValidHttpUrl("ftp://example.com"); // false, wrong protocol
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!