How can I make this REGEX cleaner?
Posted
by
Solignis
on Stack Overflow
See other posts from Stack Overflow
or by Solignis
Published on 2011-01-12T20:51:40Z
Indexed on
2011/01/12
20:53 UTC
Read the original article
Hit count: 221
I have this regex I made to compare OS names to a line in a VMX file. It started out as seperate elsif statments but I ended up making into a single if statment. Anyhow here is the code, I am trying to find a way to make the code cleaner but it put each match on a seperate line it no longer works.
elsif ($vmx_file =~ m/guestOSAltName\s+=\s"Microsoft\sWindows\sServer\s2003,Web\sEdition"|"Microsoft\sWindows\sSmall\sBusiness\sServer\s2003"|"Microsoft\sWindows\s2000\sAdvanced\sServer"|"Microsoft\sWindows\s2000\sServer"|"Microsoft\sWindows\s2000\sProfessional"|"Microsoft\sWindows\s98"|"Microsoft\sWindows\s95"|"Microsoft\sWindows\sNT\s4"/) {
$virtual_machines{$vm}{"Architecture"} = "32-bit";
© Stack Overflow or respective owner