Basically, all you have to do is convert both strings to lower case, and compare the length of the original string with the length of that string where the string to find has been removed. In VBScript:
<% x = "one" y = "two one two two one two two one two" interimString = replace(lcase(y), lcase(x), "") response.write((len(y) - len(interimString)) / len(x)) ' another way: x = "one" y = "two one two two one two two one two" response.write ubound(split(lcase(y), lcase(x))) %> |
In T-SQL:
DECLARE @x VARCHAR(10), @y VARCHAR(64) SELECT @x = 'one', @y = 'one two two two one two two one two' SELECT (DATALENGTH(@y) - DATALENGTH ( REPLACE(LOWER(@y), LOWER(@x), '') )) / DATALENGTH(@x) |