I’m not sure I understand. Would you like to take the first 54 lines of a text?
Would that be what you’re trying to do?
(.*\n){54}
If not, more details showing what you have on the screen, and what you want to catch. It would be easier to understand by visualizing what you have and what you want.
EDITED
I don’t know if you can use naming the catch, but if you can I think it would be easier:
/(?P<paragrafo>.*)(.*\n){1,54}/g
Or else it should work too:
/(.*)(.*\n){1,54}/g
The first catch (.*)
will catch the first paragraph, the second catch (.*\n){1,54}
will catch 54 paragraphs also counting the first. But then in your code just ignore this second catch. And the modifier at the end /g
will ensure that regex captures how much to find text.
The scheme I put in {1,54}
is that it will run until the end, even q the last capture battery does not get to have 54 full paragraphs. If put just like this: {54}
It will require that all catch batteries have 54 paragraphs, and if the last one has for example 53 paragraphs or less, it will ignore and will not perform the first capture of the last battery.
I hope you’re not too confused to understand ^^
Split by n and take the position of the array
– fernandoandrade
Does it have to be using pure regex? No alternatives available in languages?
– Jefferson Quesado
Why
\n{54}
is not an option?– Sergio
@However, with n{54} I did not get results. You have already succeeded in this way?
– Antonio Oliveira
@Antoniooliveira yes: https://jsfiddle.net/Sergio_fiddle/hLm9f1xv/
– Sergio
Funny, it didn’t work now. Thank you!!: https://regex101.com/r/7kyfVA/1
– Antonio Oliveira