How to get multi line matches in view.find
. For example:
use abcd;
use efjh;
With view.find("use .*;", 0)
it just returns first line(In regex101 with global flag will match both lines). I’ve tried find_all
but returns one region per line.
How to get multi line matches in view.find
. For example:
use abcd;
use efjh;
With view.find("use .*;", 0)
it just returns first line(In regex101 with global flag will match both lines). I’ve tried find_all
but returns one region per line.
But it view.find('use (.|[\r\n])*;', 0)
will match till any ;
:
<?php
use Abcd;
use Efgh;
function();
will match till end of file
I want to match just those use
statement lines. And I want to use global flag in view.find
. https://regex101.com/r/ZpesuG/1
That looks exactly what find_all does and you’ve mentioned it. So I am confused what’s wrong with find_all?
I mean one region that specifies two or more lines, not two region per one line
That’s not how region is designed. https://www.sublimetext.com/docs/api_reference.html#sublime.Region
You have to merge them by your own rule.
By the way, those two regions are not “connected” since there is an newline char between them.
In regex101 with global flag it gives 2 separate matches for me.
.
matches any character except line terminators (it even says so on the right in regex101), which is what I believe OP wants to change.
Try use (.*\n?)*;
instead