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.
精彩评论