How do I get rid of this "(" using regex?

Posted by Solignis on Stack Overflow See other posts from Stack Overflow or by Solignis
Published on 2011-01-06T08:27:02Z Indexed on 2011/01/06 8:53 UTC
Read the original article Hit count: 169

Filed under:
|

Hi there, I was moving along on a regex expression and I have hit a road block I can't seem to get around. I am trying to get rid of "(" in the middle of a line of text using regex, there were 2 but I figured out how to get the one on the end of the line. its the one in the middle I can hack out.

Here is the snippet I am searching for in the config file. I put 2 examples.

guestOSAltName = "Ubuntu Linux (64-bit)"

guestOSAltName = "Microsoft Windows 2000 Professional"

Here is the snippet I am working on.

    if ($vmx_file =~ m/^\bguestOSAltName\b\s+\S\s+\W(?<GUEST_OS> .+[^")])\W/xm) {
    $virtual_machines{$vm}{"OS"} = "$+{GUEST_OS}";
} else {
    $virtual_machines{$vm}{"OS"} = "N/A";
}

I am thinking the problem is I cannot make a match to "(" because the expression before that is to ".+" so that it matches everything in the line of text, be it alphanumeric or whitespace or even symbols like hypens.

Any ideas how I can get this to work?

This is what I am getting for an output from a hash dump.

$VAR1 = {
      'NS02' => {
                  'ID' => '144',
                  'Version' => '7',
                  'OS' => 'Ubuntu Linux (64-bit',
                  'VMX' => '/vmfs/volumes/datastore2/NS02/NS02.vmx',
                  'Architecture' => '64-bit'
                },

© Stack Overflow or respective owner

Related posts about regex

Related posts about perl