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

Get Characters from Inside String Between Symbols

Status
Not open for further replies.

thec0dy

IS-IT--Management
Apr 16, 2010
41
US
6156661199 [ Mike Jones ] TEST1, NAME1 (3_15_2013).pdf

I have a string like the one above. I need to get three more elements out of this string.
1. DName which would be anything between the brackets [ ] as in Mike Jones
2. PName which would be anything after the ] bracket and before the ( parenthese as in TEST1, NAME1.
3. Date which would be anything between the ( ) parenthese as in 3_15_2013.

 
You can use the InStr function to find the positions of the "[", "]", "(", and ")" characters. With this information you can use the Mid function to extract portions of the string between those positions.
 
Or use Regular Expressions.

\[.*\] would match between brackets (the name)

\].*\( between a closing bracket and an opening paranthesis (TEST,NAME)

\(.*\) the text inside paranthesis (date)

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Or use the Split function:
aString="6156661199 [ Mike Jones ] TEST1, NAME1 (3_15_2013).pdf"
DName = Trim(Split(Split(aString,"[")(1),"]")(0))
PName = Trim(Split(Split(aString,"]")(1),"(")(0))
theDate = Trim(Split(Split(aString,"(")(1),")")(0))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top