use strict;
my $str = '1394ohci 1394 OHCI-совместимый Kernel
3ware 3ware Kernel 19.05.2015 3:28:03
ACPI Драйвер Microsoft ACPI Kernel
AcpiDev Драйвер устройств с AC Kernel
acpiex Microsoft ACPIEx Drive Kernel
acpipagr Драйвер агрегатора про Kernel
AcpiPmi Драйвер устройства изм Kernel
acpitime Драйвер ACPI Wake Alar Kernel
Acx01000 Acx01000 Kernel
ADP80XX ADP80XX Kernel 10.04.2015 1:49:48
AFD Драйвер дополнительных Kernel
afunix afunix Kernel
ahcache Application Compatibil Kernel
amdgpio2 Драйвер GPIO-клиента A Kernel 07.02.2019 14:32:20
amdi2c Служба контроллера I2C Kernel 20.03.2019 9:57:33
AmdK8 AMD K8 драйвер процесс Kernel
AmdPPM Драйвер процессора AMD Kernel
amdsata amdsata Kernel 14.05.2015 17:14:52
amdsbs amdsbs Kernel 12.12.2012 2:21:44
amdxata amdxata Kernel 01.05.2015 5:55:35
AppID Драйвер AppID Kernel
applockerflt Драйвер фильтра Smartl Kernel
bindflt Windows Bind Filter Dr File System
bowser Браузер File System
BtFilter BtFilter Kernel 25.01.2019 10:46:26';
my $regex = qr/(?P<Module>^\w+)+\s+(?P<Name>.{1,}(?=Ke|Fi))+(?P<Type>(Kernel|File System))/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html