G
G
gomer17262018-08-16 19:51:52
JavaScript
gomer1726, 2018-08-16 19:51:52

How to cut a line?

There is this line: http://test.ru/admin/import.
You need to take only a word importfrom all this, that is, the second in a row.
The problem is that addresses can change, for example: http://test.ru/user/profile.
Here you only need to take profile.

var str = "http://test.ru/admin/import"; 
str.substring(/ здесь не могу придумать регулярные выражения /);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-08-16
@gomer1726

At first glance, regular expressions are not needed here: . And on the second one too: . But if you really want to, then you can do this :. Or like this: . str.split('/').pop()
str.replace(/.*\//, '')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question