The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 12:49pm
Pages: 1
Send Topic Print
String trim in SKILL (Read 6029 times)
adesign
Community Member
***
Offline



Posts: 73

String trim in SKILL
Jan 23rd, 2007, 2:47am
 
Could you please let me know if there is any way to trim a string in SKILL?

e.g.
Given string is ABCDEFG, MNOPEFG, IJKLEFG, WXYZEFG

I want ABCD, MNOP, IJKL, WXYZ and trim out EFG from the above.

Any suggestions...............
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: String trim in SKILL
Reply #1 - Jan 23rd, 2007, 6:12am
 
The hard way would be to use parseString and buildString, ie
result = buildString( parseString( "MNOPEFG", "EFG"))

Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
bernd
Senior Member
****
Offline



Posts: 229
Munich/Germany
Re: String trim in SKILL
Reply #2 - Jan 23rd, 2007, 9:21am
 
If you're sure that the string have always this character index


1234567
ABCDEFG

12345678
MNOPEFG


you can also use

substring( "MNOPEFG" 1 4 )


Bernd
Back to top
 
 

Just another lonesome cad guy
View Profile WWW   IP Logged
bernd
Senior Member
****
Offline



Posts: 229
Munich/Germany
Re: String trim in SKILL
Reply #3 - Jan 23rd, 2007, 9:30am
 
Or very blown up, if you know that "EFG" were always the 3 last characters.


t_myString =  "MNOPEFG"
t_result = substring( t_myString 1 length( parseString( t_myString "" ) ) - 3 )
Back to top
 
 

Just another lonesome cad guy
View Profile WWW   IP Logged
adesign
Community Member
***
Offline



Posts: 73

Re: String trim in SKILL
Reply #4 - Jan 23rd, 2007, 11:22pm
 
Thank you all for the help!!
Back to top
 
 
View Profile   IP Logged
adesign
Community Member
***
Offline



Posts: 73

Re: String trim in SKILL
Reply #5 - Jan 24th, 2007, 2:22am
 
Here is one more improved version:

rexCompile("EFG$") ; pattern meaning EFG at end of string ($ means end of string)
rexReplace("ABCDEFG" "" 1) ; replace first occurrence of pattern with blank.

Regards,
Back to top
 
 
View Profile   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: String trim in SKILL
Reply #6 - Jan 24th, 2007, 2:16pm
 
Aw, you could have credited me  ;)

Your last append looks remarkably like http://www.cdnusers.org/Forums/tabid/52/view/topic/postid/3057/forumid/62/tpage/... ...

(I don't mind really, honest)

Andrew.
Back to top
 
 
View Profile WWW   IP Logged
adesign
Community Member
***
Offline



Posts: 73

Re: String trim in SKILL
Reply #7 - Jan 24th, 2007, 10:21pm
 
Yes Andrew,

It is taken from there only!!!

Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.