Please tell me how the expression on JS should look like in order to delete all words after the first word?
For example: "Vasya Ivanovich Pupkin". You just have to get "Vasya." Words are always different ...
Please tell me how the expression on JS should look like in order to delete all words after the first word?
For example: "Vasya Ivanovich Pupkin". You just have to get "Vasya." Words are always different ...
Not necessarily something to cut. You can work through the separator and take its first element.
var str = 'Вася Иванович Пупкин' console.log(str.split(' ')[0]);
Source: https://ru.stackoverflow.com/questions/509094/
All Articles
indexOf(' ')
and delete, starting with it. You can turn a string into an array, breaking it up by the spacesplit(' ')
- and taking the zero element of the array. You can catch only the first word with a regular expression viapreg_match()
. Try to find documentation with examples on these methods and write at least some code. - Sergikspreg_match()
course, meant.match()
:) - Sergiks