- In Vim, greedy matching is used by default. In order to use non-greedy matching, you can use \{-}, or \{-n,m}, such as: :/Q.\{-0,200}[IL].\{-0,2000}FF.
- In Perl, default matching is also greedy. To use non-greedy matching, please change
*
,+
,?
, and{}
into*?
,+?
,??
, and{}?
, respectively. - To count the number of matching in Vim, you can use command “:%s/<pattern>//g”. After get the number of matches, then execute “:u” to undo the changes.
- In Perl, to count the number of matching, you can use command:
my $number =()= $string =~ /\./gi;
References:
- http://vimregex.com/
- http://stackoverflow.com/questions/1849329/is-there-a-perl-shortcut-to-count-the-number-of-matches-in-a-string
- http://docstore.mik.ua/orelly/perl/cookbook/ch06_16.htm