I’m writing an app to find and replace parts of text in the rows of a listbox, i’ve got most of it working but cannot get InStr to find apostrophes in the string value to replace it
More on this.
I am Searching a TextArea for single quotes and double quotes and it is not finding them in
my routine.
note: CmpPattern and CmpReplace are regular expression routines that have proven to work in oodles of routines and multi apps
ItemDescription is a textarea
Dim DQ As String = Chr(34) // double quote
Dim SQ As String = Chr(39) // single quote
if CmpPattern(ItemDescription.text, "[" + DQ + SQ + "]+") = True Then
ItemDescription.Text = CmpReplace(ItemDescription.Text, DQ, """)
ItemDescription.Text = CmpReplace(ItemDescription.Text, SQ, "'")
end if
note: Instr also fails the comparrisio
if Instr(ItemDecription.Text, DQ) > 0 then
end if
however this does work where ItemText is a Text Field.
if CmpPattern(ItemTitle.text, "[" + DQ + SQ + "]+") = True then
ItemTitle.Text = CmpReplace(ItemTitle.Text, DQ, """)
ItemTitle.Text = CmpReplace(ItemTitle.Text, SQ, "'")
End if
i am perplexed as to why the comparrision works in one case with a Text Field but fails with a TextArea
// Turn OFF Smart Quotes
#If TargetCocoa Then
Dim value As Boolean = False
Declare Function NSClassFromString Lib "Cocoa" (aClassName As CFStringRef) As Ptr
Declare Function documentView Lib "Cocoa" selector "documentView" (obj_id As Integer) As Ptr
Declare Sub setAutomaticQuoteSubstitutionEnabled Lib "Cocoa" selector "setAutomaticQuoteSubstitutionEnabled:" (id As ptr, value As Boolean)
Declare Sub setAutomaticDashSubstitutionEnabled Lib "Cocoa" selector "setAutomaticDashSubstitutionEnabled:" (id As ptr, value As Boolean)
Declare Sub setAutomaticTextReplacementEnabled Lib "Cocoa" selector "setAutomaticTextReplacementEnabled:" (id As ptr, value As Boolean)
Dim myTextArea As ptr = documentView(Self.Handle)
setAutomaticQuoteSubstitutionEnabled(myTextArea, value)
setAutomaticDashSubstitutionEnabled(myTextArea, value)
setAutomaticTextReplacementEnabled(myTextArea, value)
#EndIf
Dim xStart As Integer=Me.SelStart
Dim xLen As Integer=Me.SelLength
Me.Text = ReplaceAll(Me.Text,&u201C,dblQUOTE)
Me.Text = ReplaceAll(Me.Text,&u201D,dblQUOTE)
// single quotes
Me.Text = ReplaceAll(Me.Text,&u2018,sngQUOTE)
Me.Text = ReplaceAll(Me.Text,&u2019,sngQUOTE)
// lower right quotes
Me.Text = ReplaceAll(Me.Text,&u201A,sngQUOTE) //
Me.Text = ReplaceAll(Me.Text,&u201E,dblQUOTE) //
Norm,
my eyes are not what they used to be but i believe the single quotes are just straight not curley, just neutral.
and double quotes are just double quotes.
Note: at one time my routines worked, now they do not work.
They can be a bugger to spot visually
Sometime I just zoom the screen in on my Mac to be sure
And then poke at the binary in the string to see for sure