I am trying to capture the last digits in this line in a regex group:
Input:
9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654
My template:
/Power_On_Hours.+Always\s.+([0-9]{1,5})/
I just can't get it to capture "54654", it returns undef :(
Actually, this capture group should capture "4", not undef. Your last .+will eat everything up to the last digit, and then fix it up $1. This revision captures all numbers up to $1:
.+
$1
/Power_On_Hours.+Always\s.+?(\d{1,5})/
? .+ , , (\d).
?
\d
friedo, , .+ ( ), , .+?.
.+?
, , $ , :
$
/Power_On_Hours.+Always.+?(\d+)$/
#!/usr/bin/perl use strict; use warnings; my $s = q{9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654}; my ($interesting) = $s =~ /([0-9]{1,5})\z/; print "$interesting\n";
,
$string= q(9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654); @s = split /\s+/,$string; print $s[-1]."\n";
/.+Power.+Always.+[^\d](\d+)$/;
use strict; use warnings; my $string= q(9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654); my @array = split /\s+/,$string; print "$array[$#array]\n";
, ?
my ($digits) = $input =~ /(\d+)$/;
A character $binds a group to one or more digits,, (\d+)to the end of a line.
(\d+)
(?:Power_On_Hours.+Always\D*)(\d+)
It worked for me
http://regex101.com/r/oS8sO5
Source: https://habr.com/ru/post/1733258/More articles:Manipulate HTML from Firefox Extension - firefoxBuying Microsoft SQL Server 2008 Web Edition - sqlКак мне заполнить поля города/штата на основе zip? - language-agnosticРазвертывание Java-приложения как сервлета - javaList.Contains returns false, although it seems like it should return true - containsJava EE and GWT authentication - java-eeUnable to use collections with InExpression - nhibernateSphinx and word forms - sphinxGet a list of available drives and their sizes - cA double experiment of neural networks (one logical, one emotional)? - neural-networkAll Articles