Answer the question
In order to leave comments, you need to log in
How to parse URL correctly?
We have a link -->
<a [routerLink]="['/dashboard/micebot/?a=serv11111121']">/micebot</a>
Answer the question
In order to leave comments, you need to log in
if("<a [routerLink]=\"['/dashboard/micebot/?a=serv11111121']\">/micebot</a>".search(/\?a=[a-z1-5]{12}[^a-z1-5]/) == -1){
window.location ="redirect url";
}
It's better to separate the part with the parameters, and then break it into parts like key=value
.
It will be a universal solution.
It would be easier to do exactly what you asked: check for "a" immediately after the question mark:
var text = `<a [routerLink]="['/dashboard/micebot/?a=serv11111121']">/micebot</a>`;
var m = text.match(/\?a=([a-z1-5]*)/);
if (m) {
let a = m[1];
console.log('"a" существует и равно ', a);
if (a.length == 12) console.log('Длина "a" ровно 12, не больше');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question