Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete part of a string on the fly

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!

This might be easy but I just can't find the right function.
myString is e.g. "This is my special string"
I need a function which eliminates 'special'
Some like =(myString,'special')
This should return "This is my string"

-Bart
 
Hi Nifrabar,
The function you want is strtran()
for example:
MyString = strtran("This is my special string", "special")
? MyString && This is my string
 
Thanks, I knew there was a function but just couldnot find that fast.

-Bart
 
I *think* you might want to be a bit more 'clever':

Code:
MyString = strTran(strtran("This is my special string", "special"),"  "," ")
? MyString    && This is my string

Regards

Griff
Keep [Smile]ing
 
Be sure to use "special " or " special" as the search string or you will end up with two adjacent spaces in the sentence.a


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
Or you could also call reduce() after strtran() to make sure there are no double spaces. See

Code:
SET LIBRARY TO HOME()+"foxtools.fll"
myString="This is my"+space(20)+"special string."
?myString
?reduce(myString," ")
?reduce(myString,"s ")
?reduce(myString,"special ")
?reduce(strtran(myString,"special","")," ")

obj=CREATEOBJECT("shell.application")
obj.Open(HOME()+"foxtools.chm")
RELEASE obj
 
Hi Fawks!

Thanks again for spending time solving my question!
And indeed, the smarter the better....

-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top