algorithm - What is the fastest implementation of ColdFusion's listFindNoCase function in Javascript? -
i've grown spoiled coldfusion's lists, , have run across situation or 2 comma delimited list shows in javascript. there equivalent of listfindnocase('string','list')
, or performant way implement in javascript?
oh, , should able handle list items commas, like: ( "smith, john" , "doe, jane" , "etc..." )
that's tripping me up.
you can use indexof
combined .tolowercase()
var list = '"smith, john" , "doe, jane" , "etc..."'; if(list.tolowercase().indexof('"smith, john"'))
if need exact match, "smith" when "smithson" exists, pad strings delimiter. example, let's delimiter semi-colon (because have commas in string), pad left , right sides of string so:
";smith, john;doe, jane;"
also pad search value, if you're looking smith, value become:
";smith;"
.tolowercase().indexof()
return -1 (not found). ";smith, john;"
return 0
Comments
Post a Comment