Sunday, August 19, 2012

regex – Javascript: regexp to remove .html

I am searching for some regexp which remove the .html extension of a string.


I already found these two for some reason they don\’t work:



var path = \'./views/contacts/node/item.html\';
var otherPath = path;
path.replace(/\\.[^/.]+$/, \'\');
console.log(path);
// returns ./views/contacts/node/item.html
otherPath.replace(/(.*)\\.[^.]+$/, \'\');
console.log(otherPath);
// also returns ./views/contacts/node/item.html


Any idea what\’s wrong?






Rating: 5 out of 5 based on 3 ratings



The post regex – Javascript: regexp to remove .html appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/regex-javascript-regexp-to-remove-html.html

2 comments:

  1. Good job!You know I admire you for this matter, so smart you are. I can use it to the Guild Wars 2 Store promoter. Thanks!

    ReplyDelete
  2. Cherish what you already have and do not feel sorry about what you have lost. Most people just complain all the day and ignore something really important. Be a person who are good at discover the beauty of life. Then you will live a happy one.



    -------------------------------------------------------------------------------------------
    Diablo 3 power leveling, D3 power leveling

    ReplyDelete