Product Compare › Forums › Multi-Edit › Support › Regex match multiline blocks between two identifiable lines › Reply To: Regex match multiline blocks between two identifiable lines
First, it’s unnecessary to repeat the “start-of-line anchor” (^), and depending on exactly how the regex engine parses that symbol, doing so may result in a non-functional regex. Start-of-line is already implied by the preceding “end-of-line anchor” ($).
Likewise, Multi-Edit’s current regex engine occasionally has trouble with end anchors nested in repeats, although it’s not clear exactly what pattern causes the problem.
The revised version you posted makes better use of domain-specific knowledge to achieve a shorter regex, noting that the sought text pattern always begins with fouten and ends with informatie. Since there’s an internal limit of roughly 240 characters on the length of a regular expression after any aliases are expanded, it’s important to try and keep the length as short as is commensurate with an accurate match.
Realistically, the key changes you made were dropping the internal start anchors and adding the “minimal munch, any characters” after the end anchor within the group parentheses.
Someone (don’t remember who, or I’d credit him) a couple of years back came up with an alias to match two symbols possibly separated by multiple lines. It’s defined as [code:11c9rszi](.@$.@)@.@[/code:11c9rszi]and commonly added to the alias list in Multi-Edit as <ml>. Then you use it like so: [code:11c9rszi]symbol1<ml>symbol2[/code:11c9rszi]
I’m not sure exactly what you’re asking in re repeat operators; the standard minimal- and maximal-munch versions of “match any number, including zero” (the so-called “Kleene Star”) and “match any number, but at least one” are implemented. The operators for “match zero or one” and “match from m to n” are not (although see the next paragraph).
As for using a regex plugin, don’t bother. The 9.1 upgrade will include full Perl-standard regular expression support using a completely different engine than the current one. Speaking personally, that’s one of my strongest motivations to upgrade, as I use regular expressions constantly. Up to this point, whenever I ran across a regex I wanted to write that was too complex for Multi-Edit’s search engine, I ran ActivePerl externally to get Perl regexes. With 9.1, it’s native. There are a lot of nice new features in 9.1, but this is the big one for me.