Good question! I tried a few that I thought would work and didn’t get the results I imagined I would. I am definitely going to try to sit down and figure this out tomorrow because assumed this would have been pretty easy to accomplish in ways similar to the ones you showed.
In the meantime, one workaround would be to use the following regular expression as a search:
It isn’t going to bring you right to the line you want, but the line you want will be at the beginning or end of the matched text. I am new to regex so this might not even work the way I think, if at all, but it might be a start.
I look forward to seeing how this can be accomplished in a more elegant way.
It’s for me not quite clear what you want. The term “line” doesn’t exist, therefore you can’t match a “line”. You can match a paragraph or a sentence but no line. Obsidian uses the term “line”, but I think the meaning is paragraph.
@AMGMNPLK You are right. It doesn’t work. When I tested the regex, I didn’t look carefully enough at the results to realize that it only works when both string1 and string2 are on the same line. @CawlinTeffid had actually mentioned something on a different thread about Obsidian’s regex possibly being based on lines. And, I guess if this is any indication, it is.
I meant to test things further or at least respond yesterday when I saw that you mentioned it hadn’t worked. Sorry it has taken me so long. I’ll let you know if I can get something working. It is definitely worth trying to figure out.
Yes, that’s the problem, Regular Expressions are expensive and therefore I see - only with Regular Expressions - no (good) solution for that.
It is possible, but it lasts too long. The following should work. It’s just an example, without some special cases or a lookbehind as an alternation. It will freeze but if you wait you’ll get a result.
A solution would be, to collect the files containing foo with a simple string function and then a simple RegEx as in the query I posted before.
query: foo /^.*?ipsum.*/
“and run some kind of macro”
Good idea, I don’t think it’s “convoluted”, in the contrary. As far as I know (but I don’t no how) it’s possible to run macros (->shell commands) or JavaSript files inside Obsidian (maybe with Templater or Dataview).