I want to replace text by using regex, i am using xojo 2021 r.1.1
the code seems to work but not replacing the text that start with pipe followed by the number
Listbox data
Test 1 | 1234567
Test 2 | 234567
Test 3 | 678903
dim nrow as integer
for nrow = 0 to Listbox1.listcount -1
dim rx1 as new RegEx
rx1.SearchPattern = "\| [0-9]+"
dim match1 as RegExMatch = rx1.Search((Listbox1.Cell(nrow, 0)))
if match1 is nil then
else
Listbox1.cell(nrow, 0) = rx1.Replace(Listbox1.cell(nrow, 0), "")
end if
next
thanks
arief
Var rx As New RegEx
rx.SearchPattern = "\| [0-9]+"
rx.ReplacementPattern = ""
Var rxOptions As RegExOptions = rx.Options
rxOptions.ReplaceAllMatches = True
For nrow As Integer = 0 To Listbox1.LastRowIndex
Listbox1.CellTextAt(nrow, 0) = rx.Replace( Listbox1.CellTextAt(nrow, 0) )
Next