regex - How do the curly braces work in this Ruby Split line -


this question has answer here:

i have been recommended following line of code use on text file:

arr = str.split(/\n{2,}/).map { |s| s.split(/\n/) } 

am trying understand how the:

(/\n{2,}/) 

part working , does.

the leading , trailing / mark beginning , end of regular expression. \n match single newline. {2,} after symbol (in case \n) match occurrence of symbol repeated 2 or more times, in case 2 or more consecutive newlines. had been \n{3,6}, match consecutive newlines repeated between 3 , 6 times.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -