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: Strip Leading and trailing spaces from string
Topic Summary:
Created On: 4-Oct-2006 09:29
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.
Answer This question was answered by Pekka Mäkinen, on Friday, October 6, 2006 11:33 AM

Answer:
This is the function which I use (probably copied off some Telelogic code). The main idea is to use the isspace character function to check if character is space, tab, new line or some other "space-like" character and then adjust the string beginning / ending accordingly.
 4-Oct-2006 09:29
User is offline View Users Profile Print this message


David McMahon

Posts: 16
Joined: 15-Apr-2005

I am developing a small function to strip leading and trailing spaces from a string.
We have got a working version using regular expressions (see attached code),  I was wondering does any one else know a better way of achieving this..
Incidently for some unknown reason in Doors 7.1  the lenght of the buffer is alway 1 greater than the size of the data stored within it. We have allowed for this when extractings data,  Is this also the case for Doors 8?

Report this to a Moderator Report this to a Moderator
 4-Oct-2006 10:01
User is offline View Users Profile Print this message


Pekka Mäkinen

Posts: 276
Joined: 18-Mar-2004

Answer Answer
This is the function which I use (probably copied off some Telelogic code). The main idea is to use the isspace character function to check if character is space, tab, new line or some other "space-like" character and then adjust the string beginning / ending accordingly.

-------------------------
Pekka.Makinen@softqa.fi
SoftQA Oy -http://www.softqa.fi/

Edited: 4-Oct-2006 at 10:02 by Pekka Mäkinen
Report this to a Moderator Report this to a Moderator
 5-Oct-2006 18:01
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Be advised that defining a regular expression takes a rediculously large amount of time. Since your regular expressions are static (are not based on input paramaters) the speed of your function is better off if the regular expressions are moved from inside the function to outside. My naming conventions would name them "gl_reStartBlanks" and "gl_reFinishBlanks", or actually "gl_reStripSpacesStart" and "gl_reStripSpacesEnd", where "gl_" means global variable intented only for use 'locally' by a library function, 're' is for the type RegExp, and "StripSpaces" is the name of the function that uses them.

Also, you probably want to strip 'white space' which as best as I can determine is this string:
string cl_White = " \t\n\r\f\b" charOf(11) ""
// that last one (charOf(11)) is an MS-Word Line Feed, but I don't recall why I'm including it.

- Louie
Report this to a Moderator Report this to a Moderator
 5-Oct-2006 22:00
User is offline View Users Profile Print this message


Andrew Wallen

Posts: 18
Joined: 23-Sep-2006

I have also found that if you call regexp within a function, memory gets consumed, but does not get released until the dxl has ended. Try running this script, I notice a 8 MB change after running the regexp command 1000 times (no change at all when running the dummy version without the regexp). Once the script exits, all memory seems to be reclaimed.
Report this to a Moderator Report this to a Moderator
 6-Oct-2006 11:37
User is offline View Users Profile Print this message


David McMahon

Posts: 16
Joined: 15-Apr-2005

Many thanks to everyone.......

 I have used the isspace()  solution rather than Regular expressions, thus avoiding the performance / memory usage issues associated with using regular expressions.

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.