I’d like to parse a text line by line, searching for a given string.
It could be done with use of the search
-operator, but I want to know in which line it occurs.
The text can contain comments on random lines, too.
Comment lines aren’t counted for the matching line.
I think I need some recursive function or procedure for parsing the text line by line:
Can a “global” counter variable be realized for the line numbers?
Or a marker for memorizing the last found position and can be used in another run as the start position?
# Tiddler title: SampleData
#################################
# First line: comment
# Second line: comment
Some text;separated by;semicolon
# Another line, another comment
More text;separated by;semicolon
More text;follows
My first thought for stripping out the comment lines:
\function new.line() [charcode[10]]
\function get.text() [{SampleData}split<new.line>] :map[<currentTiddler>search::anchored[#]count[]compare:integer:gt[0]then[comment]else[text]]
How do I call get.text
recursively until a text line was found?
Thank you in advance for your comments!