View Single Post
  #4  
Old 07-24-2015, 04:37 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 998
I'd use a regular expression, since the data you want seems to follow the pattern of VL_\d+_.
In the pattern above, \d+ means one or more digits

For example, since you have read the line of output into a strResults var...

Code:
' One example of your output - hardcoded for testing only
strResults = "1:73 98984477_dfegeerVL_8473_98984477 D R"

Set re = new RegExp
re.IgnoreCase = False
re.Pattern = "(VL_\d+)_"
'              |____|
'                ||
'   Data that matches pattern between
'   1st set of ()s will be known as:
'   ...Submatches(0)


If Not re.Test(strResults) Then
    crt.Dialog.MessageBox _
        "Pattern '" & re.Pattern & "' wasn't found: " & _
        vbcrlf & vbcrlf & strResults
    crt.Screen.SendSpecial("MENU_SCRIPT_CANCEL")
Else
    Set objMatches = re.Execute(strResults)
    strDataWeAreAfter = objMatches(0).Submatches(0)
    crt.Dialog.MessageBox "Here's what we extracted: " & strDataWeAreAfter
    '...
End If

More information about regular expressions can be found in the SecureCRT scripting guide (see chapter 4.3's sub-section titled, "Extracting Specific Information"), as well as in the MS VBScript documentation for the Regular Expression Object.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote