• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Get string from middle of phrase

What would be the most efficient way to get rid of the leading and training characters in the following string

FORM_FrmTestForm.txt

That is, get rid of the FORM_ and traling .txt to leave only FrmTestForm
0
ssmith94015
Asked:
ssmith94015
  • 2
2 Solutions
 
Patrick MatthewsCommented:
If the string ALWAYS has a underscore and period, AND the period always comes after the underscore...

Left(Mid(SomeString, InStr(1, SomeString, "_") + 1), InStr(1, Mid(SomeString, InStr(1, SomeString, "_") + 1), ".") - 1)
0
 
Rey Obrero (Capricorn1)Commented:


try this

Dim x
x = "FORM_FrmTestForm.txt"
x = Mid(x, InStr(x, "_") + 1)
x = Left(x, Len(x) - 4)


that will give you   "FrmTestForm"
0
 
ssmith94015Author Commented:
Let me try both and be right back.
0
 
ssmith94015Author Commented:
Both worked, however I went with the one-line version in this procedure.  This scenario always has the first five and last three but I do have another process that will have variable strings.   Thank you both.

Sandra
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now