I am trying to achieve this and I don’t believe it can’t be done with regex, albeit I would have probably done it with scripting already …
I have a bunch of text files that have multi-line text that fits in between lines that start with a dash (as the first non-blank character on that line). So each such multi-line text might have, on the last line before the dash-starting line below, a line that starts with “>” and contains, somewhere on that line, a hashtag.
Here is one such example:
- ffff
- aaa
* bbb
* ccc
- tttt
* aaa
* bbb
> #tag
- tttt
* aaaa
* bbbb
> #log
-
I have managed to get the text in between dashes but I can’t seem to be able, for the life of me, to speciufy another rule, that in between those dashes there should be a line starting with “>” and containing the tag “#log” -for example:
(^s*)(-[sSn]+?(?=^s*-))
Is there a way, with REGEX, to match each multiline text in between dash-starting lines that contains, on it’s last line, “>.#log.$”?
I tried many many variations like tis one:
(^s*)(-[sSn]+?(?=>.*#log.*$ns*-))
This basically gets everything (greedy?), from the first dash in the file up to the line starting eith “>” that is followed by a newline starting with dash. So it does what it says it dows I just don’t know how to tell it that I don’t want any lines starting with dash in the match.
I somehow want to tell it to only consider the last dash-starting line (non-greedy?)…
Thank you for saving my sanity 🙂
sothor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.