![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() 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 | |
![]() |
|
Need to extract a substring from a string,
the string I start with is "some substring ![]() I want to end up with "some substring" ie the colon and any characters that occur after it are excluded. thanks for any advice |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
Many thanks to both for help-Martin |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
extracting a substring
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.