Skip to the content.

text_extract_with_mark_f.rb(ys1)

Extracts lines from the specified file that match the start line pattern and organizes them into ParentAndChild objects.

contents of text_extract_with_mark_f.txt

header1
1
header2
1
2
header3
1
2
3

Execution:

require "ys1"
#=> true

YS1::Text.extract_with_mark_f("text_extract_with_mark_f.txt", /^header/)
#=> 
[#<YS1::ParentAndChild:0x00007f24c3632858 @children=["1"], @parent="header1">,
 #<YS1::ParentAndChild:0x00007f24c3632628
  @children=["1", "2"],
  @parent="header2">,
 #<YS1::ParentAndChild:0x00007f24c3632380
  @children=["1", "2", "3", ""],
  @parent="header3">]

Executed with Ruby 3.3.6