Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 2 of 2 total |
Efficient search of text |
Mon, Jan 23 2017 8:23 AM | Permanent Link |
Matthew Jones | I have to search for some text in an object which has 12 strings, mixed case. There may be hundreds of these, and I'd like to do it as fast as possible. The instant solution is Pos(search, itemtext), but that is case sensitive. So I am currently using Lowercase on the search term, and then doing Lowercase on each of the 12 values, each time.
szSearch := LowerCase(szSearch); for nLoop in all items do begin bFound := Pos(szSearch, LowerCase(m_szHumanName)) > 0; if not bFound then bFound := Pos(szSearch, LowerCase(m_szAddress1)) > 0; // repeat 12 times end; Now I could write a case insensitive Pos, but I suspect that would actually add more code. Anyone know of a better way to do this? Hmm, I could append all the strings and lowercase that, but would it really help? -- Matthew Jones |
Wed, Jan 25 2017 2:05 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
<< I have to search for some text in an object which has 12 strings, mixed case. There may be hundreds of these, and I'd like to do it as fast as possible. The instant solution is Pos(search, itemtext), but that is case sensitive. So I am currently using Lowercase on the search term, and then doing Lowercase on each of the 12 values, each time. >> That's the best solution for now, and what is normally recommended for such operations in native JS. You can also use regular expressions in JS, but that gets messy with escaping, etc. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |