Good afternoon,
I have a notepad with several lines typed as for example:
★ Bayonet
★ Bayonet | Autotronic (Battle-Scarred)
★ Bayonet | Blue Steel (Minimal Wear)
★ Bayonet | Case Hardened (Battle-Scarred)
★ Bayonet | Case Hardened (Factory New)
★ Bayonet | Case Hardened (Field-Tested)
In my code one of the lines will wait for input on the keyboard asking what name you want to find
use strict;
open(FILEHANDLE,'<','filtradas.txt') or die "Arquivo não pode ser aberto\n";
my @linhas = <FILEHANDLE>;
close(FILEHANDLE);
print "Informe o nome do item que deseja encontrar: ";
my $nome = <STDIN>; chomp($nome);
foreach my $linhas(@linhas) {
chomp($linhas);
if($linhas =~ m/$nome/gi) {
print $linhas."\n";
}
}
The question is: Is there any way to create a regex that if for example I type in the keyboard input "Bayonet Case" it will print me all the results of the notepad that contains Bayonet + Case on the same line? In case:
★ Bayonet | Case Hardened (Battle-Scarred)
★ Bayonet | Case Hardened (Factory New)
★ Bayonet | Case Hardened (Field-Tested)
I'm sorry if I could not be clear, if you did not understand I'd try to explain it some other way.
Thank you in advance.