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

extract a string

Status
Not open for further replies.

mayrou

Electrical
Joined
Jan 8, 2014
Messages
55
Location
TN
Hello world!
I want to extract a string from an other
for example dossier1\dossier2...\123-Mayrou\forum
for that I used SPLIT to extract "mayrou"

mayrou =Right(Split(productDocument1.Path,"\")(2),4)

Anybody please correct it.
Thanks in advance :)
 
I want to extract a string between two
...\Mayrou\...
 
Depending on what you want to extract (and which language are you using, for example is much easier in vb.net) it can be done in different ways

Bellow is an example using different functions (just to understand how is working),

Code:
Dim MyString, TrimString, RightTrimString, FinalString

MyString = "dossier1\dossier2\123-Mayrou\forum" 

MyStringNr = Len(MyString)
MsgBox MyStringNr

LeftTrimStringNr = InStr(MyString, "Mayrou")
MsgBox LeftTrimStringNr

RightTrimString=Right(MyString, MyStringNr - (LeftTrimStringNr-1))
MsgBox RightTrimString

FinalString = Left(RightTrimString,Len("Mayrou"))
MsgBox FinalString

or in your code

Code:
Dim MyString, FinalString

MyString = "dossier1\dossier2\123-Mayrou\forum" 
strToExtract = "Mayrou"
FinalString = Right(Split(MyString, "\")(2),Len(strToExtract))
MsgBox FinalString

Regards
Fernando

 
thx you Fernando :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top