Home > Enterprise >  Regex exclude /live and any url with dot from url
Regex exclude /live and any url with dot from url

Time:09-08

I have links:

/yktqxw
/fzvenbr/ohwtbl.css <
/osfqimq/live
/live <
/srjtsuv/qmvqgkz

I need to exclude link start /live and has any dot like /folder/style.css /image.png /js/script.js

My regex is

/^\/(?!(live))(?![\.])(?:.*)/gm

But I have problem with exclude url witch dot

https://regex101.com/r/DDDQAq/1

CodePudding user response:

Your second negative lookahead excludes links that start with a dot instead of those containing a dot. This will match all links on their own - if you need proper multiline support, you might want to add "\r\n" to the list of excluded charactes in the square brackets: https://regex101.com/r/yC0pXR/1 If you only need to match single urls, you don't need that.

^\/(?!live)[^.]*$

CodePudding user response:

This is the expression you are looking for. You can also check it out here https://regex101.com/r/T5AfU9/1 take care!

/^\/(?!live)(?!(?:.*(?:[.]))).*$/gmi

  • Related