Answer the question
In order to leave comments, you need to log in
How to remove everything superfluous from a line after the 2nd slash?
Good day
I ran into a problem due to the fact that I don’t know regex well
, for example, there is a string (url)
market/catalog/sea/test/test2/test3
how can I cut everything that comes after sea including a slash so that the output is a string of this type
market /catalog/sea
instead of sea can be any word with any number of letters
Answer the question
In order to leave comments, you need to log in
"market/catalog/sea/test/test2/test3".split('/').slice(0, 2).join('/')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question