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: function Find and Replace any string
Topic Summary:
Created On: 8-Aug-2007 12:49
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.
 8-Aug-2007 12:49
User is offline View Users Profile Print this message


Thomas Langholz

Posts: 40
Joined: 20-Oct-2005

Hi, though i could not find this kind of function, i wrote it myself. This function is a familiar strreplace function. Thanks to Stuart for the key-idea. regards thomas
Report this to a Moderator Report this to a Moderator
 8-Aug-2007 14:06
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

I guess everybody writes this routine from time to time ... :-)

Just one note: it was posted here from time to time, that regular expressions are quite memory and time consuming. If you use your routine in a massive loop, this could be an issue. I'd therefore propose to create one routine taking the regexp as argument, and a second, overloaded routine with your original arguments. Thus you have both options, and if you find yourself using the same search and replace in a long loop, you could take the version with regexp as argument. The attached script runs less than 1 second when the regexp is created once, and 6 seconds when the regexp is created in each step. Plus the latter one consumes more memory.

Regards,

Peter
Report this to a Moderator Report this to a Moderator
 8-Aug-2007 16:07
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Yes, regexp is pretty slow. The famous example would be the function that determines if the raw text contains 'shall'; you are much better off declaring Regexp HasShall = regexp([S|s][H|h]..] outside that function, rather than inside.

I think you should be more conserned with the massive memory leak associated with the way you break apart and put the string back together. You should put the string into a buffer and use buffer combine functions to rebuild the string. Using a loop instead of recursion should likewise save time and space.

Also be advised that both examples given work only on raw text. Rich Text replaces are a lot trickier.

- Louie
Report this to a Moderator Report this to a Moderator
 9-Aug-2007 10:41
User is offline View Users Profile Print this message


Thomas Langholz

Posts: 40
Joined: 20-Oct-2005

Hi all, thanks for your useful advice. @Louie - if i'm forced to do this with rich text, ill contact you so log thomas
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 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 2 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.