![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: replacing '&' Topic Summary: Created On: 15-Jul-2005 08:28 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: The search for & will find the & in &, and replace it with &amp, then with &ampamp... You need to move the start point for your search to just after where you found the last &. I was going to attach a code snippet, but I don't know what it needs to be - still you've got the theory now... ![]() | |||
![]() |
|||
Hello,
I have a little problem. I am parsing some text for exporting to DocBook. In the text, there might also be source code included, which has some '&' in it. So now in DocBook you must replace those with "&" as some of you might know. I attached my code beneath, so you can see what i have tried so far. When i add the searchfunction for the '&' the script runs endlessly ... Without the '&' while, it works perfectly ... Thanks in advance Ben |
|||
![]() |
|||
![]() |
|||
The search for & will find the & in &, and replace it with &amp, then with &ampamp...
You need to move the start point for your search to just after where you found the last &. I was going to attach a code snippet, but I don't know what it needs to be - still you've got the theory now... ![]() ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive Edited: 15-Jul-2005 at 08:42 by Paul Tiplady |
|||
![]() |
|||
![]() |
|||
arf, you are so right ... i didnt think of that ... thanks for your help
![]() Ah i see the problem now, too ... The offset parametre isnt the offset from where he searches the string ... Maybe i can try text[index:end] .... Edited: 15-Jul-2005 at 08:46 by Ben Herfurth |
|||
![]() |
|||
![]() |
|||
Ooh! Another thought. You could replace & with !amp;, then replace !amp; with &. That would also get around the problem.
------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|||
![]() |
|||
![]() |
|||
hm i think that would be easier then setting the offset new in every run ...
![]() |
|||
![]() |
|||
![]() |
|||
Ben, the following funtion did the job for me. There is some extra stuff in this function that you may not need so you might want to strip these bits out.
------------------------- Tony Goodman http://www.smartdxl.com Edited: 15-Jul-2005 at 11:52 by Tony Goodman |
|||
![]() |
|||
![]() |
|||
hey that's quite a nicething
![]() i didn't think of writing a own funtion, cause there were already function which should do the same for me ![]() i will try yours. Thanks |
|||
![]() |
|||
![]() |
|||
You may find this function of use. This takes a rich text parameter and returns docbook text.
It distinguishes between requirements and other information using paragraph roles.
------------------------- Tony Goodman http://www.smartdxl.com |
|||
![]() |
|||
![]() |
|||
that function really works fine. i added another option which you'll see below
but that one won't kill the control characters ![]() maybe because they appear as a square (unknown character) in Doors, but when i open it with my VI they appear as a ^Y and a ^S do you have any idea how that could work? |
|||
![]() |
|||
![]() |
|||
I had a lot of trouble with special characters when writing this.
Could you test for the ascii value and then reject the character if it is not within some defined ranges? In other words test for ALL the chracters that you WANT and reject everything else. ------------------------- Tony Goodman http://www.smartdxl.com |
|||
![]() |
|||
![]() |
|||
hmm yes would be the only possibilty then narf ... dealing with special chars is really a big thing. And you'll never find all of them
edit: ok a comparison with "intOf(oldStr) == 19" or char char19 = charOf(19) oldStr == char19 doesn't work either ![]() Edited: 15-Jul-2005 at 12:53 by Ben Herfurth |
|||
![]() |
Telelogic DOORS
» DXL Exchange
»
replacing '&'
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.