### [SOLVED] Any faster ways than InStr() to search huge text?

Posted:

**02 Mar 2015, 11:11**I'm trying to get the exclude list, by comparing sub list and full list.

For example:
thanks.

For example:

Test code:Full List: contains 100,000 numbers (00000,00001,00002...99999). 599999 characters.

Sub List: contains 60,000 numbers (00000,00001,00002...59999). 359999 characters.

I want to get the remaining numbers (from 60000 to 99999). It takes about 50 seconds in my computer. Is there some faster ways, like using MCode?

Code: Select all

```
CreateTestData(100000Numbers, 10) ; contains 100000 numbers (00000,...,99999)
CreateTestData(60000Numbers, 6) ; contains 60000 numbers (00000,...,59999)
startTime := A_TickCount
40000Numbers := ""
Loop, Parse, 100000Numbers, CSV ; loop 100000 times
If !InStr(60000Numbers, A_LoopField)
40000Numbers .= "," A_LoopField
MsgBox, % (A_TickCount-startTime)//1000 ; it takes 51 seconds in my computer
Return
; ===========================================================
CreateTestData(ByRef result, n) {
result := ""
Loop, % n
{
n1 := A_Index - 1
Loop, 10
{
n2 := A_Index - 1
Loop, 10
{
n3 := A_Index - 1
Loop, 10
{
n4 := A_Index - 1
Loop, 10
{
n5 := A_Index - 1
result .= "," n1 n2 n3 n4 n5
}
}
}
}
}
result := Trim(result, ",")
}
```