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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract value from string

Status
Not open for further replies.

FoxKid

MIS
Jun 8, 2003
92
IN
I am having a string like this
"asdga/ser"
"asd/sdagasdfg"
"asdf_asd/asdfg"
Now I want to pick the value as follows
"asdga"
"asd"
"asdf_asd"
How is it possible?

Thanks n Regards
 
?SUBSTR("asdga/ser",1,AT("asdga/ser",'/')-1)
?SUBSTR("asd/sdagasdfg",1,AT("asd/sdagasdfg",'/')-1)
?SUBSTR("asdf_asd/asdfg",1,AT("asdf_asd/asdfg",'/')-1)

 
Thanks IoriYagami
But u have done a small mistake.....
it should be like this
?SUBSTR("asdga/ser",1,AT('/',"asdga/ser")-1)
?SUBSTR("asd/sdagasdfg",1,AT('/',"asd/sdagasdfg")-1)
?SUBSTR("asdf_asd/asdfg",1,AT('/',"asdf_asd/asdfg")-1)

Thankyou once again for your idea....
 
Thanks for correcting my mistatke... Ha... do u ever try the SuperCombo From Chris in the faq184-1891. If yes pls let me know the result...
 
FoxKid,
This is one of those times when using a function for other than what it was written for also works:
Code:
?JUSTPATH("asdga/ser")
?JUSTPATH("asd/sdagasdfg")
?JUSTPATH("asdf_asd/asdfg")
or in VFP 7 & 8
?getwordnum("asdga/ser",1,"/")
?getwordnum("asd/sdagasdfg",1,"/")
?getwordnum("asdf_asd/asdfg",1,"/")
or in VFP 6
set library to home()+"foxtools.fll"
?wordnum("asdf_asd/asdfg",1,"/")
...
Rick


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top