![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Effective Searches Topic Summary: Created On: 26-May-2004 22:35 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I've got search functions that work, but do a VERY ineffecient job searching for SubStrings in the main String. Basically I get the length of the SubString and search for it in position 0 of the String; then in position 1, etc. Lots of string extraction. When the calling program does NOT want to "matchcase" I just "lower" both String and SubString before searching.
Its VERY innefficient. I'm now searching huge projects and such searches takes hours. I strong suspect memory leak. I need a better function. The Buffer "contains" function runs 10 times faster but has that nasty provision that the SubString must be preceeded by a non-alpha character. Likewise "keyWord". "findRichText" does a good job on raw text but actually finds the offset of raw text and NOT within the text iteself (RT formatting is skipped). Anybody got some search function (preferably buffer)? How about a reference to an effective search algorithm? Can I really do with the RegExp (which is my personal blind spot)? - Louie |
|
![]() |
|
![]() |
|
Louie,
The simplest way I've found to search text is to use regular expressions which are fast enough for the applications I've used it for. The following is a basic example to check for a match: // the text you're looking for String searchText = "shall" // search text converted to a regular expression Regexp rSearchText = regexp searchText // the text you're looking in String textToSearch = thisObject."Object Text" if ( rSearchText textToSearch ) { // text found - do something } Another example of using regular expressions is here... Regular expressions example ------------------------- Stuart Gilbey C4 Systems Limited www.c4systems.co.uk |
|
![]() |
|
![]() |
|
I'll need to get the Offset into the String of the first occurance of SubString. I assume if Offset < 0 then String doesn't contain SubString.
|
|
![]() |
|
![]() |
|
From that other thread I derived the code:
Offset = -1 Regexp encodeStr = regexp SubString if ( encodeStr InBuffer) { InBuffer[match 1] Offset = start 0 } Running my tests reveals this seach is accurate but 30 times SLOWER than my other search, which looked for SubString in InBuffer at position 0, and if not found look for it starting at position 1, yaddy. The "contains" command was 10 times faster than my existing search but inaccurate. Doesn't seem like Regexp is the way to go here. - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Effective Searches
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.