Regex capture next line in text file

Nick_Mulholland
Sat, 08 Jul 2023 19:28:09 +0000
General Usage

I’m fairly next to Julia and was wondering if anyone had some advice. I’m loving the regex feature which is working great on a line by line query for example

open(filename) do file
        for (index, ln) in enumerate(eachline(file))
            m = match(r"\s+<minimizedAffinity>\s*",ln)
            if m != nothing
print(m)
end

However I struggling with how to do read in the whole file and find matches for a multiline pattern. i.e the float value that comes after the keyword.

(\s+<minimizedAffinity>[\n,\r]([-+]?[0-9]*\.?[0-9]+(e[-+]?[0-9]+)?))

the goal to extract a list of float values from the text file.

I can faff around with indexing the lines but there must be a more elegant solution?

8 posts - 6 participants