字符串比较

首先,写一个方法。

 

class String
  def -(s)
    self[/#{Regexp.escape(s)}/]
    $'
  end
end

 

举个例子:

 

    a = "records/task[summary/category='recreation']/records/task[summary/category='karaoke']"
    b = "records/task[summary/category='recreation']"
    c = a - b
    puts c  # => /records/task[summary/category='karaoke']

 

你可能感兴趣的:(C++,c,C#)