开发者

Javascript Look Ahead Issue!

开发者 https://www.devze.com 2023-02-16 16:15 出处:网络
Hey guys I have multiple urls with the following format... http://example.org/bloop/why-manage-risk/an/23435-PDF-ENG?N=4294956507&Ntt=why+manage+risk

Hey guys I have multiple urls with the following format...

http://example.org/bloop/why-manage-risk/an/23435-PDF-ENG?N=4294956507&Ntt=why+manage+risk

I am trying to extract eve开发者_StackOverflowrything after bloop/ up until ENG. So the result would be.

why-manage-risk/an/23435-PDF-ENG

I have read that using something like (?<=product/).*ENG in javascript will not work. Does anyone else have another solution this issue?


You can also try:

url.replace(/bloop\/(.*?ENG)/, '$1');


Try using a capturing group:

var result = s.match(/bloop\/(.*?ENG)/)[1];


You could try:

var bloopToEng = url.replace(/^http.*bloop\/(.*-ENG).*$/, '$1');


If that is your current URL, you can simply grab location.pathname.

Else, go for Mark's answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消