The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 String manipulation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
illysam Posted - 02/23/2004 : 10:41:45 AM
I have a string of the following format:

token1 token2 token3 token4 ...

What's the best way to delete a single token from that string? The problem is that only the token text is known while the position of the token is variable.

Thanks, Rolf.
3   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 02/25/2004 : 10:34:46 AM
Hi Rolf.

You can also use a simple substring notation:
%[%A," token"] %[%A,>"token "],

e.g.,
  %a="abc bcd cde";
  type %[%A," bcd"] %[%A,>"bcd "];
  abc cde

Though it seems that this works only when the search token is a literal.

Hiedo Fujii
  OriginLab

rlewis Posted - 02/23/2004 : 12:05:06 PM
If you have Origin 7.0 or higher you can also try the OriginC option. The following (or something like it) should work

 
bool delete_token (string &InputString, string TokenString)
{
/*
Deletes the string "TokenString" from the string "InputString"
*/
string LocalCopy="";
int i=0;
while (i<InputString.GetNumTokens())
{
string strToken=InputString.GetToken(i);
if (strToken.Compare(TokenString)!=0)
{
LocalCopy+=strToken;
LocalCopy+=" ";
}
i++;
}
InputString=LocalCopy;
return (true);
}
Mike Buess Posted - 02/23/2004 : 11:45:01 AM
Hi Rolf,

One way is to examine each token like this...
%R=string;
%S=token_to_delete;
%T="";
for(i=1; i>0; i++) {
%A=%[%R,#i];
if( %A=="" ) break;
if( "%A"!="%S" ) %T=%T %A;
};

...There is a shorter way to do it but I can't to get the expression to appear in a forum message. Email me if you're interested.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 02/23/2004 11:47:01 AM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000