Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete line break

Status
Not open for further replies.

tamaro

IS-IT--Management
Apr 8, 2003
37
US
I'm looking for a way to delete the line break on text file the data is as follows.

200 product name
Level: EACH
201 Product 2
Level: EACH

i want to basically find where it says Level and bring it to the line above like.

200 product 1 Level: EACH
201 Product 2 Level: EACH

any help will be apreciated.
 
Sample is good. But you've to tell what feature is generic.
 
i guess i dont understand. Level: is always there i guess i just want to find where is says "level:" go to the begining of the line and delete the line break.
 
>i guess i dont understand
Okay, I guess you would when you don't receive the response to perform what you like to have.
[tt]
'your givens here[green]
infile="xyz.ext"
outfile="abc.ext"[/green]

set fso=createobject("scripting.filesystemobject")
set f=fso.getfile(infile)
if f.size<>0 then
s=f.openastextstream(1).readall
set f=nothing
else
set f=nothing
set fso=nothing
wscript.quit
end if

set rx=new regexp
with rx
.pattern="\r?\n(\s*Level:.*\r?\n)"
.ignorecase=true
.global=true
end with

s=rx.replace(s,"$1")
fso.opentextfile(outfile,2,true).write s

set fso=nothing
[/tt]
 
i got this to work.

Do Until ActiveDocument.Bookmarks("\Sel") = _
ActiveDocument.Bookmarks("\EndOfDoc")
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Level:"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

If Selection.Find.Found = True Then
Selection.HomeKey Unit:=wdLine
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine
Else
Exit Do
End If
Loop

is pretty simple but does what i need. i will try yours to see if it runs faster because the document is 3000 pages.
 
Thank you very much tsuji, this worked perfectly while i was still waiting for my script to finish runing yours got it done in less than a minute. Thank you!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top