Need help - make a simple regular season:
str = 'New/123/папка/123/713' It is necessary to cut the string from the end to the / character. The expression must be universal. Grateful for the help.
Need help - make a simple regular season:
str = 'New/123/папка/123/713' It is necessary to cut the string from the end to the / character. The expression must be universal. Grateful for the help.
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
var str = 'New/123/папка/123/713'; //разбиваем строку в массив var arr = str.split('/'); //удаляем последний элемент массива arr.pop(); //формируем новую строку var newStr = arr.join('/')+'/'; console.log(newStr); var str = "New/123/папка/123/713", rgx = /([aA-zZ0-9-]+$)/; console.log(str.replace(rgx, "")); str.slice(0, str.search(/([aA-zZ0-9-]+$)/)) - Evgeny NikolaevSource: https://ru.stackoverflow.com/questions/908587/
All Articles
str.substring(0, str.lastIndexOf("/") + 1)- Wiktor Stribiżew