I’m using Ruby, and I want to write a function that takes a delimited string str (delimited by //), and returns the final part of the string, that is, the part after the last // in the string. For example, given a//b///cd, it should return cd.
Can I use a regular expression to do this, and if so, what expression should I use?
As Nhahtdh wrote in his comment you can use
/.*\/\/(.*)/Which in Ruby, would be something like
You can find about the
%rin theRegularExpressionsection of theProgrammingRuby.