I want to transfer the results between Regex and two words to an array, but unfortunately I couldn’t this. Can you help me?
In this text
[row] Row text1 [rowEnd] [row] Row text2 [rowEnd]
I will search this content,
[row] (.*) [rowEnd]
Based on this I write a regex like this
However, this way, it takes the whole, not piece by piece.
Thank you in advance for your help.
^Start of string
[row]and a newline
(Capture group 1
[^]*?Match 0+ times any char including a newline non greedy
)Close group 1
r?n[rowEnd]Match a newline and
const regex = /^[row]r?n([^]*?)r?n[rowEnd]/gm; const str = `[row] Row text1 [rowEnd] [row] Row text2 [rowEnd]`; Array.from(str.matchAll(regex), m => console.log(m));