![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() 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. | |
![]() |
|
I am developing a small function to strip leading and trailing spaces from a string. |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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.
|
|
![]() |
|
![]() |
|
Many thanks to everyone....... |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Strip Leading and trailing spaces from string
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.