This question has already been answered:
- Replacing all occurrences 2 replies
The task is to divide arbitrary text and remove unnecessary possible characters, such as "." or for example ",". How to do it? It worked for me in the console, but in the whole code does not work. And how to check for all possible signs? For each write a separate line? After all, it can also be "!" be for example.
var text = prompt('Введите любой произвольный текст', 'Футбол это игра, целью которой является забить мяч в ворота противника'); var textArr = text.split(' '); for (i = 0; i < textArr.length; i++) { textArr[i].replace(',', ''); };
var textArr = text.split(/[\s,]+/).filter(Boolean);and without any cycles and replacements. - Qwertiy ♦.match(/[а-я]+/gi)and not on split :) - Grundyaz?) And match still has a null case that gets mixed up) - Qwertiy ♦