Searching a Very Long String - Efficiently (Classic ASP)

When it comes to string handling, ASP isn't the most efficient. The easiest code to write is simply instr(1,ucase(search),ucase(find)), and then check the result for > 0. The problem comes with extremely long strings. I needed to search a very long string of values from each line of CSV. It was actually much faster to split each line into its individual elements and search one cell at a time. Here is the code.

Function CheckSearchString(sToCheck,sList)

	Dim aItems
	Dim bFound
	Dim i
	bFound = False
	
	aItems = Split(sList, ",")
	For i = lBound(aItems) to uBound(aItems)
		If instr(1,ucase(sToCheck),uCase(aItems(i))) > 0 Then 
			bFound  = true
			Exit For
		Else
		'	Response.Write sToCheck
		End If
	Next
	
	CheckSearchString = bFound

End Function

AuthorInfo

Joe is a User Experience Engineer, Front End Specialist and Application Developer for Bridgeway Software, Inc and part-time consultant for NGO and non-profit organizations in the Houston area. Joe is also a part-time Portrait Photographer at MEDIA.24Moves.com and organizer of the HoustonPhotowalks.com photography club. He and his wife Marty run the AutismHouston.com Support and Playdate group.

-

@ext237

-

@drupaltips

-

Flickr

-

LinkedIn

-

Ports

-

Contact


Fatal error: Class CToolsCssCache contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (DrupalCacheInterface::__construct) in /home/content/e/x/t/ext237/html/modules/ctools/includes/css-cache.inc on line 52