regexp in VX help

I have the following script in VX Ace:

Code:
      case line
      when /<down\s*(\w+)\s*(\d+)\s*(\d+)>/i # <down Damage4 3 2> in note
        @down_name = $1
        @down_x = $2.to_i
        @down_y = $3.to_i

When it runs, those variables are populated correctly with the regexp results.

I've done a similar thing in VX:

Code:
      case script
        when /forget_all\(\d+\)/
          cmd.code = 356
          cmd.parameters[0] = sprintf('ForgetSkills %d', $1.to_i)

and while it matches the expression successfully, $1 is always 0.

I have also changed it to
Code:
      if script =~ /forget_all\(\d+\)/
          cmd.code = 356
          cmd.parameters[0] = sprintf('ForgetSkills %d', $1.to_i)

but it gives the same results. Same with putting it into a variable and using the variable in the sprintf (I didn't think it'd make a difference, but in an attempt to exhaust all possibilities ...)

Does regexp behave a little differently in the VX version of Ruby? What do I need to change to make it pick up the correct digits from the original string?



Edit:

Aaaargh! Should've known as soon as I asked for help here I'd figure it out! I needed to add some extra ()

Code:
      case script
        when /forget_all\((\d+\))/

But I knew you were all here for me, and that's what matters 🙂

Moderator note: Closing

Original thread: https://forums.rpgmakerweb.com/threads/regexp-in-vx-help.135346/