我想创建一个正则表达式,以匹配不以特定单词结尾的URL。以下是一些示例:
我要匹配:
**getEventos():Observable<Event[]>{
//get todos os eventos
return this.http.get<Event[]>(this.url_node, httpOptions).map(response=> response.Events);// map operstor takes your response and sends the Events array as a part of the response for your HTTP call.
}**
而且,我不想匹配:
https://google.com/default-category/all-products.html/22-oz-full-color-stadium-cup-white
https://google.com/catalog/product/view/id/9351/s/plant-award/category/3/
https://google.com/all-products/volleyball/stress-shape
这是我正在使用的正则表达式:
https://google.com/all-products/timber-bases-other/bases-gloves/tic-tac-1/tic-tac-1/
https://google.com/all-products/timber-bases-other/bases-gloves/tic-tac-1/tic-tac-1/tic-tac-1/tic-tac-1/tic-tac-1/
问题是,所有单词都遵循类似的模式。通配符https?:\/\/(www\.)?google\.com\/(default-category\/all-products\.html|catalog\/product\/view\/id|all-products)\/[\w-\/]+(?!tic-tac-1)
甚至与单词([\w-]+\/?)+
匹配。
如何确保它不会发生?
这里是RegExr链接,我在这里尝试:https://regexr.com/4chb8