[Edinburgh-pm] Regex not matching what I expect (or want:)

Iain Barnett iainspeed at gmail.com
Sat Jul 31 09:21:43 PDT 2010


Hi,

If I run this (perl 5.12):

$n = "8907455758584";
@ns = $n =~ /\d{3}/g;
print "@ns";

I get this:
890 745 575 858

I expected (and wanted) this:
890 907 074 745 455 557 575 758 585 858 584


I'm not sure why it's not backtracking to look at the string again?

Any help is much appreciated.

Regards,
Iain


More information about the Edinburgh-pm mailing list