Skip to content
Prev 181453 / 398503 Next

split strings

Monica Pisica wrote:
one way that seems reasonable is to use sub:

    output = sub('.*//(.*)[.]tif$', '\\1', input)

which says 'from each string remember the substring between the
rigthmost two slashes and a .tif extension, exclusive, and replace the
whole thing with the captured part'.  if the pattern does not match, you
get the original input:

    sub('.*//(.*)[.]tif$', '\\1', 'f:/foo/bar//buz.tif')
    # buz  

vQ