![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Replacing a character in a string Topic Summary: Created On: 23-Oct-2007 15:23 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hi,
I am trying to write a dxl that replaces the first character of a string with a different character, if the string meets certain conditions. I've figured out how to use regular expressions to test against those conditions, but I can't figure out how to do the actual replacement of the character (and also to limit it so that the character is only replaced if it is the first character in the string). Can anyone offer any help? Thanks in advance. |
|
![]() |
|
![]() |
|
Regrettably you cannot just change the first character; this doesn't work: S[0] = 'R'. You have to rebuild the string:
NewString = 'A' OldString[1:] - Louie |
|
![]() |
|
![]() |
|
Here is an approach:
string s = "this is a test" if(s[0:0]== "t") s = "T" s[1:] print s |
|
![]() |
|
![]() |
|
thanks for the replies guys, it helped me come up with something.
|
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Replacing a character in a string
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.