Quick reference for efficient coding
Extracts lines from the specified file that match the start line pattern and organizes them into ParentAndChild objects.
text_extract_with_mark_f.txt
header1
1
header2
1
2
header3
1
2
3
require "ys1"
#=> true
YS1::Text.extract_with_mark_f("text_extract_with_mark_f.txt", /^header/)
#=>
[#<YS1::ParentAndChild:0x00007f13d0a0dcb0 @children=["1"], @parent="header1">,
#<YS1::ParentAndChild:0x00007f13d0a0da30
@children=["1", "2"],
@parent="header2">,
#<YS1::ParentAndChild:0x00007f13d0a0d620
@children=["1", "2", "3", ""],
@parent="header3">]
Executed with Ruby 3.3.5