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: extracting a substring
Topic Summary: extracting a substring
Created On: 4-Jan-2006 11:37
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.
Answer This question was answered by cliff Bly, on Wednesday, January 4, 2006 4:06 PM

Answer:
If you just want to extract 1 instance of the substring use the code below. (note: no error checking if the substring is not found - if posn == -1 then return null)


If you want to extract more than 1 instance, you will need to add a loop of some sort.

If you want to replace the substring look at http://www.smartdxl.com/forum/viewtopic.php?t=4
 4-Jan-2006 11:37
User is offline View Users Profile Print this message


martin allman

Posts: 74
Joined: 25-Jul-2005

Need to extract a substring from a string,
the string I start with is "some substringther characters"
I want to end up with "some substring" ie the colon and any characters that occur after it are excluded. thanks for any advice
Report this to a Moderator Report this to a Moderator
 4-Jan-2006 13:45
User is offline View Users Profile Print this message


cliff Bly

Posts: 58
Joined: 11-Apr-2003

Answer Answer
If you just want to extract 1 instance of the substring use the code below. (note: no error checking if the substring is not found - if posn == -1 then return null)


If you want to extract more than 1 instance, you will need to add a loop of some sort.

If you want to replace the substring look at http://www.smartdxl.com/forum/viewtopic.php?t=4

-------------------------
Cliff Bly


Edited: 4-Jan-2006 at 13:48 by cliff Bly
Report this to a Moderator Report this to a Moderator
 4-Jan-2006 13:47
User is offline View Users Profile Print this message


Oliver Röpke

Posts: 42
Joined: 23-Nov-2005

Hi Martin,

well, getting a substring is quite easy, if you know the range of of the original string:
string str = "some substring other characters"
string sub_str = str[0:13]  // where 0 is start index and 13 is end index
print sub_str

See also chapter "Operations on type string" in DXL refernce manual.

Is that to you problem? I cannot find any constraints or preconditions in you mail so that's the easiest way to get a substring. In certain cases you may need to find the appropriate index values, e.g. by using regular expressions.

Best Oliver

-------------------------
Greetings,<BR>Oliver<BR><BR><BR>Oliver Roepke<BR>Axis Engineering AG, Munich
Report this to a Moderator Report this to a Moderator
 4-Jan-2006 16:09
User is offline View Users Profile Print this message


martin allman

Posts: 74
Joined: 25-Jul-2005

Many thanks to  both for help-Martin

Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 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 1 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.