Ruby REGEX split, any issues with the code -
i rookie in regex ruby. read tutorials , evaluated piece of code. please let me know if can in better way. here text needs split @ {iwsection(*)} , {{usersection}} t='{{iwsection(1)}} has sample text 1 - line 1 has sample text 1 - line 2 {{iwsection(2)}} has sample text 2 {{iwsection(3)}} has sample text 3 {{usersection}} user section. has sample text has sample text' here ruby regex code able manage. t.split(/^({{[i|u][wsection]\w*...}})/) thank you. the desired output : array as, [ '{{iwsection(1)}}', 'this has sample text 1\nthis has sample text 1 - line 2', '{{iwsection(2)}}', 'this has sample text 2', '{{iwsection(3)}}', 'this has sample text 3', '{{usersection}}', 'this user section\nthis has sample text\nthis has sample text.'] with build hash, { '{{iwsection(1)}}' => 'this has sample text 1\nthis ha...