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: Replacing a character in a string
Topic Summary:
Created On: 23-Oct-2007 15:23
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.
 23-Oct-2007 15:23
User is offline View Users Profile Print this message


Michael Venos

Posts: 20
Joined: 26-May-2004

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.
Report this to a Moderator Report this to a Moderator
 23-Oct-2007 15:37
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 23-Oct-2007 15:38
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Here is an approach:

string s = "this is a test"
if(s[0:0]== "t") s = "T" s[1:]
print s
Report this to a Moderator Report this to a Moderator
 23-Oct-2007 18:20
User is offline View Users Profile Print this message


Michael Venos

Posts: 20
Joined: 26-May-2004

thanks for the replies guys, it helped me come up with something.
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.