/// Zap selection with spaces

var hMainWnd=AkelPad.GetMainWnd();
var nSelStart;
var nSelEnd;
var pSelText;
var pResult;
var oPattern;

if (hMainWnd)
{
  nSelStart=AkelPad.GetSelStart();
  nSelEnd=AkelPad.GetSelEnd();
  if (nSelStart == nSelEnd)
    AkelPad.SetSel(0, -1);

  pSelText=AkelPad.GetSelText();
  oPattern=new RegExp("[^\u0000-\u00ff]", "g");
  pSelText=pSelText.replace(oPattern, "  ");
  oPattern=new RegExp("[^\r]", "g");
  pResult=pSelText.replace(oPattern, " ");
  AkelPad.ReplaceSel(pResult);
}