
Reiner Hutsch wrote:
-----Ursprüngliche Nachricht----- Von: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] Im Auftrag von John Maddock Gesendet: Mittwoch, 23. September 2009 18:45 An: boost-users@lists.boost.org Betreff: Re: [Boost-users] [Regex] Group of number at line end
i am looking for a regular expression which extracts a group of number from the end of a line like the following:
"This line may contain digits (9) but ends with numbers like 1 2 3 4 5"
When using a regex like "^(.+)(\\s+(\\d+))+$" I receive "This line may contain digits (9) but ends with numbers like 1 2 3 4" and "5".
Can someone help me?
What about: "^(.+)[^\\d\\s](\\s+\\d+)+$"
HTH, John.
Hi John,
sorry, but this gives also only the last number.
Reiner.
If you want the group, not the each number separately, this should work: ^.*[^ 0-9] *([ 0-9]+)$ Testing with perl: perl -e '$x = "This line may contain digits (9) but ends with numbers like 1 2 3 4 5"; $x =~ s/^.*[^ 0-9] *([ 0-9]+)$/$1/g; print "$x\n";' Output: 1 2 3 4 5 Regards, Roland