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

take all characters after _

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
CA
strVar = 'abc123456_aa.bb'

I only want to take aa.bb from this variable... basically everything after the '_'

How can I do this
 
Mid(strVar, 1 + InStr(strVar, "_"))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
'VBScript:

strVar = "abc123456_aa.bb"

strArray = Split(strVar, "_")

'result:
' strArray(0) -> "abc123456"
' strArray(1) -> "aa.bb"

'OR:

strResult = Right(strVar, Len(strVar) - InStrRev(strVar, "_"))

MsgBox strResult
 
Code:
Option Explicit

Dim strTemp : strTemp = "abc_123456_aa.bb"

Dim RegEx : Set RegEx = New RegExp
RegEx.Pattern = "\_([^_]+\.\w+)"
RegEx.IgnoreCase = True

WScript.Echo RegEx.Execute(strTemp)(0).SubMatches(0)

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top