Regex alone would not help here.

I made an test script for this issue.

This script works for simple example text like:

cite:
--------------------------------------------------------------------------------
A Zeile
A Zeile
A Zeile
B Zeile
B Zeile
C Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
E Zeile
--------------------------------------------------------------------------------



and results in

cite:
--------------------------------------------------------------------------------
A Zeile
A Zeile
A Zeile

B Zeile
B Zeile

C Zeile

D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile
D Zeile

E Zeile
--------------------------------------------------------------------------------




This is an simple script with NO error handling!
_Please test with test data FIRST !_

Be sure that your text didn't have indents as tabs or 
blanks in front of the lines.



Const module_name  = "someName20110211"   'this name must be unique !!!
Const module_ver   = "0.001a"     'version of your script
'==============================================================
' name "Init" is required, its called automatically 
' during initialization to create menu items
Sub Init
'addMenuItem "Menu item", "Sub menu if wanted", "Name of Function to Call"
 addMenuItem "New line every new section", "Stefan", "DoIt"
End Sub
'==============================================================

    'Set WSH = Wscript.CreateObject("WScript.Shell")
    'Set Shell  = CreateObject("Shell.Application")
    'Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
    'vPSPadHome = getVarValue("%PSPath%")
    'vPSPadScriptFolder = vPSPadHome  & "Script"
    
'==============================================================
Sub DoIt               
  Set editor = newEditor()  'new editor object              
      editor.assignActiveEditor() 'work with active document
      vText = editor.selText() 'put selected text in variable vText
    
      If vText="" Then
          MsgBox "Please select some or all text first"
          Exit Sub
      End If

     ' here do something with this selected text
     ' e.g. splitt selected text into lines
     vArrayLines = Split(vText, vbCrlf)
 
     vCharLast =""
     vLineArray =""

    For i = 0 To UBound(vArrayLines)
        vCurrentLine = trim(vArrayLines(i))
        vCurrChar1 = left(vCurrentLine, 1) 'ToDo: detect leading blanks
  
        If (i > 1) AND (vCharLast <> vCurrChar1) Then
            vLineArray = vLineArray & vbCRLF
        End If
      
        vLineArray = vLineArray & vCurrentLine & vbCRLF
        vCharLast = vCurrChar1
    Next

    'msgbox vLineArray
    'put the text back to the active document
    editor.selText vLineArray

    Set editor = Nothing
End Sub 'DoIt
'==============================================================



'<EOF>=========================================================

'Script Language Reference ==> http://gogogadgetscott.info/pspad/functions.htm
'Macro commands ==> http://gogogadgetscott.info/pspad/macroprikaz.htm
'PSPad Scripts ==> http://www.pspad.com/de/pspad-extensions.php



HTH? :-D


.

-- 
greets,     Stefan
[img]http://pspad.milten.lima-city.de/Fan.gif[/img]  (pleased user since 1722)
[url=http://tinyurl.com/52xrj]inofficial FAQs[/url] +  
[url=http://forum.pspad.com/read.php?2,16286,page=2]Infos[/url] + 
[url=http://forum.pspad.com/read.php?6,24628]Special Settings[/url]

<http://forum.pspad.com/read.php?2,55767,55780>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem