N
N
nezzard2019-05-01 17:47:17
JavaScript
nezzard, 2019-05-01 17:47:17

How to split large text using RegEx pattern?

Good afternoon, there is a large text that is being parsed.
Before I found the problem, I split the text using split(/[ ,\r?\n]+/) everything worked like clockwork, then I could use match to go through the array and find the necessary match('^[0-9] {3,4}[xx ]+[0-9]{3,4}$')
But then it turned out that my split is not suitable, since it is designed to split if there is a space or a comma.
Here are the possible options that I you need to sort out
1280x720
1280x720 (x Cyrillic)
1280 x 720
1280 x 720 (x Cyrillic)
That is, if I break the text and the text contains this option 1280 x 720, then I can no longer find this piece.
Can you suggest how to implement this solution correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
ProjectSoft, 2019-05-01
@nezzard

It?

var txt = `1280х720,
1280х720 (х кириллица)
1280 х 720
1280 х 720 (х кириллица)`;
var arr = txt.split(/(?:,?\r?\n)+/);
console.log(arr)

https://regex101.com/r/asozT9/4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question