Remove Single, But not Multiple, Strings

Category: Strings

Date: 02-16-2022

Return to Index


 
'RegRepl version
Function PBMain() As Long
   Local temp$, iPos As Long
   temp$ = $CrLf + $CrLf + "abc" + $CrLf + "def" + $CrLf + $CrLf + "ghi" + $CrLf + "jkl" + $CrLf
   temp$ = Trim$(temp$,$CrLf)
   Do
      Incr iPos
      RegRepl "(\r\n)In temp$ With $Spc At iPos To iPos, temp$
   Loop While iPos
   ? "..." + temp$ + "..."
End Function
               
'Replace$ version
Function PBMain() As Long
   Local temp$, iPos As Long
   temp$ = $CrLf + $CrLf + "abc" + $CrLf + "def" + $CrLf + $CrLf + "ghi" + $CrLf + "jkl" + $CrLf
   Replace $CRLF + $CRLF With Chr$(0) in temp$  'change double $CRLF to %Null
   Replace $CRLF With " in temp$     'remove single $CRLF
   Replace Chr$(0) With $CRLF + $CRLF  in temp$  'replace the %Nulls with paragraph information[/CODE]
End Function
 
 
... better is next
 
Function PBMain() As Long
   Local a$,b$, iPos As Long
   a$ = "abc" + $CrLf + "def" + $CrLf + $CrLf + "ghi" + $CrLf + "jkl"
   Replace  $CrLf + $CrLf + $CrLf + $CrLf With Chr$(0) In a$
   Replace  $CrLf + $CrLf + $CrLf With Chr$(0) In a$
   Replace  $CrLf + $CrLf With Chr$(0) In a$
   Replace $CrLf With $Spc In a$
   a$ = Shrink$(a$,Chr$(0)+Chr$(0))
   Replace Chr$(0) With $CrLf + $CrLf In a$
   ? a$
End Function      
 
'gbs_01462
'Date: 10-17-2014


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm