![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Maintaining RichText Formatting Topic Summary: Created On: 19-Jul-2004 21:34 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hello,
I'm running scripts through large modules, and I would like to remove any spaces/tabs at the beginning and end of each object's text. The modules have objects with text that has mixed bolded and normal words. Is there an easy way to remove these spaces and set the text back with its original rich text formatting. I am using the following regexp to find the spaces/tabs: Regexp spaceTab = regexp "([ ])|([TAB])" NOTE: The "TAB" represents a real tab. Example of object text: Requirements - The requirements..... Thanks, John Mazzie |
|
![]() |
|
![]() |
|
John,
The regexp you want to search for is: Regexp spaceTabStart = regexp "^([ \\t]*)([^ \\t])" Regexp spaceTabEnd = regexp "([ \\t]*)$" This will search for zero or more spaces or tabs, in any order, followed by anything that isn't a space or a tab, or a start of line. Note the double \ -- you need to escape the escape character so that the regexp sees \t (a tab character). (Try searching for a double backslash in a string! ![]() For the start string, you need to return everything from the second match on, and for the end string, you need to return everything up to the character before the start of the first match. The code below gives a worked example. Cheers, Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
Thank you very much Paul. The code works great. I'm still having one problem though. If it is possible, I would like to keep the same formatting with the text(i.e. if a word is bolded, I would like it to stay bolded when I reassign the object text). Right now my code looks for anything bold in the text and if it finds something, it ends up making the entire object text bold.
o."Object Text" = richText "{\\b " ot "}" ot = altered object text (removed spaces and tabs) If anyone has any suggestions, I would greatly appreciate them. Thank you, John Mazzie |
|
![]() |
|
![]() |
|
You need to do some stuff with rich text paragraphs. You can scan through a rich text paragraph by chunk, determine the attributes of each chunk. For the first chunk, strip off the leading white space. For the last chunk, strip off the trailing white space. You'll need to check whether the first and last chunks are all white space and deal with that situation accordingly. Try the Rich Text section of the DXL manual -- there's a 'for RichTextParagraph in string' loop that will help you.
Enjoy! Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Maintaining RichText Formatting
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.