Difficulty writing a REGEX to validate URL

Asked

Viewed 94 times

-2

  • 1

    Ask only the tags related to the problem. You want to use regex in Java, Javascript or Dart?

  • For me the logic of regex is Generic... can be in anyone I understand...

  • 1

    Have you tried that: https:\/\/firebasestorage.googleapis.com\/v0\/b\/nome-app\/.+

  • 2

    It’s actually better to focus on a specific language. Regex varies a lot from one language to another and the solutions are not always the same (in this specific case maybe it is, but it is not always so)

  • @hkotsubo so it is. I even removed my answer because I found mt inconsistent.

  • 2

    It would not be enough to see if the string starts with "http://firebase...etc"? There it doesn’t even need regex, every language has a method similar to startsWith for strings...

Show 1 more comment

1 answer

1

Here’s how you can do it :)

if (a_tua_variavel.indexOf('https://firebasestorage.googleapis.com/v0/b/nome-app/') > -1){
   alert("Tem parte do link");
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.