Frank Wunderlich a écrit :
i have problems with the pattern itself...i know the function, but this pattern 
is not exactly like regexp.

my try:

function splitfilename()
  local fn=editor:GetSelText()
  --output:ReplaceSel(fn)
  local dirname=string.gsub(fn, "(.*)[^\\]*$", "%1")
  local filename=string.gsub(fn, "\\([^\\]*)$", "%1")
  output:ReplaceSel(dirname.."%"..filename)
end

but this won't work...

These are regular expressions, but not the notation you are familiar with, and a bit limited too.
Here is a function that return both parts:

function SplitDirFile(path)
  local _, _, dir, file = string.find(path, [[^(.*)\([^\]-)$]])
  return dir, file
end

It won't work for a simple file name (must have a path part), it is easy to add a check at start if needed.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --

_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to