Tcl regexp: Why is the “+” not matching the maximum possible?

I am using TCL8.4. In the following expression, I tried to get a numerical value using ([0-9] +). But this is not as much as possible, although the “+” is displayed on the man page, designed to match as much as possible (ref: http://wiki.tcl.tk/396 ) Also, please share / suggest the best way to do that what i want to do.

%set a {
NOTPLD STATS:
              Bps:                    0; pps:                    0; Bytes:                    0; Packets:                    4535

TPLD STATS:
          Bps:                    0; pps:                    0; Bytes:                    0; Packets:                    4535

}
%
% regexp {NOTPLD STATS:(.*?)Packets:[\s]+([0-9]+)} $a t1 t2 c 
1
% set c
4
+4
source share
1 answer

See Interaction between quantifiers with different greed :

, - , .

, ([0-9]+) ([0-9]+?), , , . (*?) (+?).

, ( ):

regexp {NOTPLD STATS:(.*?)Packets:[\s]+([0-9]+)\s} $a t1 t2 c
                                                ^

IDEONE

, (?:\s|$).

+4

Source: https://habr.com/ru/post/1619483/


All Articles