Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Effective Searches
Topic Summary:
Created On: 26-May-2004 22:35
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 26-May-2004 22:35
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 27-May-2004 08:53
User is offline View Users Profile Print this message


Stuart Gilbey

Posts: 4
Joined: 14-May-2003

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
Report this to a Moderator Report this to a Moderator
 27-May-2004 15:54
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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.
Report this to a Moderator Report this to a Moderator
 27-May-2004 16:25
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.