D
D
demidov5552017-04-26 00:45:47
JavaScript
demidov555, 2017-04-26 00:45:47

How to split input value into 3 parts?

There is 1 input, Surname [space] First name [space] Middle name are entered there.
The data is entered into 3 different lines separated by a space.
those.
Ivanov Ivan Ivanovich
Your Surname : Ivanov
Your Name : Ivan
Your Patronymic : Ivanovich
I don't understand how to do it, I couldn't find it in Google. I'm doing it in react.
please tell me the algorithm

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2017-04-26
@demidov555

var names = 'Иванов Иван Иванович';

console.log(names);

var re = /\\s+/;
var nameList = names.trim().split(re);

console.log(nameList);

A
Anton Ulanov, 2017-04-26
@antonsr98

break through the regular

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question