Search code examples
regexreadfilerainmeter

RainMeter multiline - RegExp


I'm trying since a couple of days to read an entire file with Rainmeter.

I'm working with WebParser and RegExp.

My result is something like this:

Line1
Line2
Line3

If I make a RegExp like (?m).*, I have only the first line. However, if I use something like (?m).*\n.*, I have the two lines...

Fantastic, but sometimes, I just have 1 line and sometimes, I can have 5 lines. If I'm writing = (?m).*\n.*\n.*\n.*\n.* and I have for example just 3 lines, Rainmeter doesn't get my lines.

Does anyone have a solution?


Solution

  • You need to use a singleline option to force the . to match newline symbols:

    (?s).*
    

    As an alternative, you can add anchors matching at the beginning and end:

    \A(?s).*\z
    

    See demo

    Unless you need to access some specific lines, you do not need the multiline flag that makes ^ and $ anchors match at the start/end of a line.