Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3677702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:15:13+00:00 2026-05-19T03:15:13+00:00

I am trying to use a regex to match another line in a VMX

  • 0

I am trying to use a regex to match another line in a VMX file but it only “half” works. I will explain.

The line I am trying to match for example is scsi0:0.fileName = "Test01.vmdk. My regex seems to work fine for that. Now the curveball, if I try to use the same regex to look for scsi0:1.fileName = "Test01_1.vmdk. My regex does not find it and only display the first disk it found for each VM. I know I am missing something I just can’t put my finger on it. The only thing that is odd but I don’t think makes any difference is the line for the second disk scsi0:1.fileName = "Test01_1.vmdk is located at the bottom of the file and the line for scsi0:0.fileName = "Test01.vmdk is at the middle of the file with more lines for other option after it. Is the regex stopping too soon? Is that even possible?

Anyhow here is the code block I am working on.

    foreach my $vm (@virtual_machines) {
    my $vmx_file = $ssh1->capture("cat $virtual_machines{$vm}{VMX}");
    my $inc = -1;
    if ($vmx_file =~ m/scsi([0-3]):([0-9]|1[0-5])\.fileName\s+=\s+"(?<DISK>\w+?\.vmdk)"/xm) {
        ++$inc;
        $virtual_disks{$vm}{"Disk$inc"} = "$+{DISK}";
    }

This is odd, but if I explicitly plug in the numbers of the SCSI id I am looking for it work. For some reason it is not able to find it on its own. I updated my example too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:15:14+00:00Added an answer on May 19, 2026 at 3:15 am

    If you want to find all matches in a string, change the if to a while and add the g modifier for global matching. @mob is also right that you should use non-greedy matching.

    The character group [0-15] is equivalent to [015]: if you want to match 0-15, then you should change this to (?:[0-9]|1[0-5]). You don’t need to escape the :. And I assume you left out the closing " in your strings by mistake when typing the question.

    Works on rubular.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a regex in Python to match a file (saved as
I'm trying to use regex to match a string that starts with a <p>
I'm trying to use a regex to match a pattern such as (letter(letter|number))* ,
I am entirely new to regex, and am trying to use it to match
trying to use regex to replace any white space with &nbsp;, inside of example
I am trying to use regex generators to create an expression, but I can't
I am trying to use Regex in C# to match a section in an
I am trying to use RegEX to match a URL pattern. I found an
I am trying to use RegEx within my Perl script to parse a file
I'm trying to use regex expressions to catch some incoming urls, but I'm having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.