I cannot seem to get the regex right which would parse the `output` so we can use `match[1-4]` later.

Something along these lines is what you're after I suppose?

````ruby
    match = /^(#{resource[:name]})-(\d[^-]*)[-]?(\w*)(\(installed\))$/.match(output)
    Puppet.debug("match: #{match.inspect}")
    Puppet.debug("0: #{match[0]}\n1: #{match[1]}\n2: #{match[2]}\n3: #{match[3]}\n4: #{match[4]}")

    if match[1] == resource[:name] and !match[4].empty?
      Puppet.debug("Package #{resource[:name]} #{properties[:ensure]} is already the latest available")
      return properties[:ensure]
    else
      Puppet.debug("Latest available for #{resource[:name]}: #{match[2]}")
      if properties[:ensure] > match[2]
        # The locally installed package may actually be newer than what a mirror
        # has. Log it at debug, but ignore it otherwise.
        Puppet.debug("Package #{resource[:name]} #{properties[:ensure]} newer then available #{match[2]}")
        return properties[:ensure]
      else
        return match[2]
      end
    end
````

This works when `output` is `bash-4.2.45p0 (installed)` but fails to match at all (`match` is `nil`) for `tcsh-6.18.01p0`
Perhaps this is something that can be refactored once this code has been merged?