vendredi 5 mars 2021

Write an IF condition to contain the exact match of letters from a link in browser's address field [duplicate]

I would like to write an IF condition that contains an exact match of letters found in a link, but the way I wrote the if, probably isn't the best method.

Can anyone help me understand better?

The condition to find the letters in the link is written below, but I think it would be better to use a RegEx. How do I write the condition in the if, to contain the RegEx?

  const findUrl = "http://wwww.example.com/dk"; 

The IF condition is written like this for now and uses only the findUrl variable. How can I write it to use the RegEx for exact matching of dk letters?

if(findUrl.includes('dk')) {
     // some code here
    }

Aucun commentaire:

Enregistrer un commentaire