Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-08-2015, 11:37 AM
jbd1300 jbd1300 is offline
Registered User
 
Join Date: Dec 2014
Posts: 18
Regular Expression Help

Hello,

Could i get help with a regular expression?

I want to differentiate between 2 devices, an ex4200-24f and an ex4550-32f.

In the CLI the lines that i need to match on look like:

Model: ex4200-24f
or
Model: ex4550-32f

I want to pull the 4200 or the 4550 from the CLI, and match on the number

The 4200 will have a different set of snaps and the 4550 will have a different set of snaps.

This is what i got so far setup.

crt.Screen.Synchronous = True
crt.Screen.IgnoreEscape = True

crt.Screen.Send "show version" & vbcr

strOutput = crt.Screen.ReadString(">")

'crt.Dialog.MessageBox strOutput

Set re = New RegExp
re.MultiLine = True
re.Global = True
re.IgnoreCase = True
re.Pattern = "\s(:\s)ex\d+\s" 'Trying to pull the ex4**0- out. looking at the whitespace after the :
'wanting to debug the regex, and see what i found
If re.Test(strOutput) Then
crt.Dialog.MessageBox re.Test(strOutput) ' pulling what the regex found and display it
'crt.Dialog.MessageBox re.Pattern
Else
crt.Dialog.MessageBox "nothing was found"
End If

Thanks
  #2  
Old 05-08-2015, 12:12 PM
jbd1300 jbd1300 is offline
Registered User
 
Join Date: Dec 2014
Posts: 18
I figured it out! I apologize to waste everyone's time.

I was making it way more difficult than it really should have been.

# $language = "VBScript"
# $interface = "1.0"
crt.Screen.Synchronous = True
crt.Screen.IgnoreEscape = True

crt.Screen.Send "show version" & vbcr

strOutput = crt.Screen.ReadString(">")

'crt.Dialog.MessageBox strOutput

Set re = New RegExp
re.MultiLine = True
re.Global = True
re.IgnoreCase = True
re.Pattern = "4200"
If re.Test(strOutput) Then
'crt.Dialog.MessageBox re.Test(strOutput) ' Will send a true
'crt.Dialog.MessageBox re.Pattern ' Will show me exactly what it finds
crt.Dialog.MessageBox "4200 snaps"
Else
crt.Dialog.MessageBox "4550 Snaps"
End If
  #3  
Old 07-24-2015, 12:03 PM
jbd1300 jbd1300 is offline
Registered User
 
Join Date: Dec 2014
Posts: 18
Thanks

I am closing this thread out, apologize for leaving it open.
Closed Thread

Tags
regular expression , scripting

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:41 PM.