Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross 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
Jan 8, 2014
55
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 :)
 
Replies continue below

Recommended for you

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top