- Code: Select all
this line I want to match, since it ends with a#
but this line I don't care about#
nor this one#
even though they're matched by the same pattern#
then more unrelated exciting stuff happens below
which other patterns will tend to
oh, and don't match this line either#
Using a simple interior pattern ^.*#$ matches every #-terminated line. To limit it, I tried adding a lookbehind to see if the line in question was preceded by the begin pattern (which would make it the first), and I also tried incorporating the entire first #-terminated line into the "begin" pattern pattern itself, but it looks like neither of those work since maching seems to be limited to one line at a time.
What I think is my only other option is to limit that interior pattern to matching a fixed number of times (for this case, just once). Is such a thing possible? Or is there another way I could match this?