I am trying to clean an URL (rss feed) such that after the last .rss (or.html) there are no further characters. I'm using the TryIt Editor on w3schools.com for testing. The following is my test code:
var str="http://rss.cnn.com/rss/cnn_world.rsstest";
var patt1=/(.*[.rss|.html]).*/g;
var result = str.replace(patt1, "$1");
document.write(result);
The problem I am having is that the result shown is
http://rss.cnn.com/rss/cnn_world.rsstest
i.e. the "test" didn't get removed. I am wondering if someone could check my regex and explain what I am doing wrong?
Thank you.