Hi folks,
one for the weekend
I got a .TXT with three lines:
unknown
unknown
pcm_s16le
and want to read out line 1, 2 and 3 separately for populating variables. For example line 3, I tried
(?im)(?:\r\n?|\n){2}(\w+) and
(?:\r\n?|\n){2}(\w+) and
\n\n(\w+) and so on...
but it returns "unknown" instead of "pcm_s16le". I tried several regex-tester (https://www.regexpal.com/ and https://regexr.com/ for example) and cruised through several forums for getting this running - but no success.
Any idea?
thanks in advance,
tom
[SOLVED] $regext() for reading out n-th line
[SOLVED] $regext() for reading out n-th line
Last edited by ThomasM on Mon Jun 17, 2019 2:54 pm, edited 1 time in total.
Re: $regext() for reading out n-th line
Hi Thomas,
this is a chance to proof that my tipp with the ".*?" from your last regex thread is actually useful. Sure there might be many ways to get this done, this is just one possible way.
All you need to know is which bytes are used for the Newline in your text document. There are basically only 2 options:
"\n"
"\r\n"
Also we need to use parantheses () to define which line we want to match, e.g.
First line
In words: match anything up to the occurence of line feed and new line character but do not include line feed and new line in the match result
Second line
Third line
full example used in Populate variables processor to match second line:
As said, depending on your text file, you might need to replace all "\r\n" by just "\n".
this is a chance to proof that my tipp with the ".*?" from your last regex thread is actually useful. Sure there might be many ways to get this done, this is just one possible way.
All you need to know is which bytes are used for the Newline in your text document. There are basically only 2 options:
"\n"
"\r\n"
Also we need to use parantheses () to define which line we want to match, e.g.
First line
Code: Select all
(.*?)\r\n
Second line
Code: Select all
.*?\r\n(.*?)\r\n
Code: Select all
.*?\r\n.*?\r\n(.*?)
full example used in Populate variables processor to match second line:
Code: Select all
$regext($read("c:\temp\newline.txt"),".*?\r\n(.*?)\r\n")
emcodem, wrapping since 2009 you got the rhyme?
Re: $regext() for reading out n-th line
Hi emcodem,
thank you for the input.
As always - works great. I´m trying hard to get this regex-thing working for me and many small expressions I can do on my own. But the more complex ones...
Now as I see it I understand it. Once again - Thank you!
regards,
tom
thank you for the input.
As always - works great. I´m trying hard to get this regex-thing working for me and many small expressions I can do on my own. But the more complex ones...
Now as I see it I understand it. Once again - Thank you!
regards,
tom