Apostrophe removal

Have written a program to filter text file but trying to remove APOSTROPHE from the file does not work.

Am using the following to do the work, if I change the apostrophe to a “/” the code works.

Dim F as Folderitem
Dim f2 as Folderitem
Dim textinput As TextInputStream
Dim inputword as string
Dim n As Integer
Dim n1 as integer
Dim t as TextOutputStream
Dim textarray() as string
Dim testword as string

f = getfolderitem(“d:\testfolder\words.txt”)
f2 = getfolderitem(“d:\testfolder\words.tmp”)

If f <> Nil And f.Exists Then

textInput = TextinputStream.Open(f)
t = TextOutputStream.Append(f2)

While Not textInput.EOF
  
  inputword = textinput.readline
  
  Textarea1.text=inputword
  
  textarray=split(inputword)
  
  n1=textarray.indexof(""")
  
  testword = join(textarray)
  
  if n1 = -1 then
    
    If f2 <> Nil then
      
      t.Write(inputword + chr(10))
      
    End if
    
  end if
  
Wend

End If
t.Close
textInput.Close

Thanks For any help.

dim s as string
dim v() as string ' buffer that will hold all the lines
textInput = TextinputStream.Open(f)
t = TextOutputStream.Append(f2)
s=replaceall(t.readall,"'","")
v=split(s,endofline)

Thank You very much used your code to alter mine and now works fine.

This won’t replace those so-called smart quotes if the file has them…

Not sure what you mean by SMART QUOTES…?

I think “smart quotes” are the ` as opposed to ’
if you need to remove those, just add another replaceall

Smart quotes are substituted by word processor programs according to typographical rules, and are part of the high ASCII characters. Here they are listed as Unicode values so it works with any font :

Lower right single quote : &U201A
Lower right double quote : &U201E
Left single quote : &U2018
Right single quote : &U2019
Left double quote : &U201C
Right double quote : &U201D

Thank you for the explanation and will set the program to do all the various characters and symbols with replaceall and see what happens.

Thank Again.

This regular expression code will do it all for you, if you are just looking to eliminate them.

dim rx as new RegEx
rx.SearchPattern = "[\\x{2018}-\\x{201f}'""]"
rx.ReplacementPattern = ""

rx.Options.ReplaceAllMatches = true

dim replacedText as string = rx.Replace( sourceText )