mainString.s = "aabgdhowz56uy6..."
and this small string
maskString.s = "6adoy6867"
the purpose is to keep only the characters in the mainString which found in maskString
we should get this result aado6y6
using the approach by Fred here: http://www.purebasic.fr/english/viewtop ... 55#p497636 for ascii and unicode mode
more ideas or codes thanks in advance
tested in v5.62 and v5.46 LTS
Code: Select all
Declare.s retain(mainString.s,maskString.s)
mainString.s = "aabgdhowz56uy6"
maskString.s = "6adoy6867"
Debug mainString: Debug maskString
Debug retain(mainString,maskString)
Procedure.s retain(mainString.s,maskString.s)
result.s = Space(Len(mainString)*2)
lng.l = Len(mainString) - 1
For i=0 To lng
char.s = PeekS(@mainString+(i*SizeOf(Character)),1)
found = FindString(maskString, char, 1)
If found
PokeS(@result+(res*SizeOf(Character)),char, 1)
res+1
EndIf
Next
ProcedureReturn result
EndProcedure