class String

def pathmap_replace(patterns, &block)

patterns take the form 'pat1,rep1;pat2,rep2...'.
Preform the pathmap replacement operations on the given path. The
def pathmap_replace(patterns, &block)
  result = self
  patterns.split(';').each do |pair|
    pattern, replacement = pair.split(',')
    pattern = Regexp.new(pattern)
    if replacement == '*' && block_given?
      result = result.sub(pattern, &block)
    elsif replacement
      result = result.sub(pattern, replacement)
    else
      result = result.sub(pattern, '')
    end
  end
  result
end