Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-07-2012, 02:40 AM
danielo515 danielo515 is offline
Registered User
 
Join Date: Sep 2012
Posts: 2
VBS - Regular Expression WEIRD BUG

Hello everybody.

I just want to report something that is pretty unusual.

May the scenario that I show here is a little bit, twisted, but here it is:
I'm using Secure CRT and Visual Basic for scripting.

I have a function to deal with regular expressions, like this, which returns an array.

Code:
function Expresion( registro, patron )
 
dim resultado
Set re = New RegExp
re.Pattern = patron
re.Multiline = False
re.IgnoreCase = False
re.GLOBAL = TRUE
resultado = ""
 
	
 
				If re.Test(registro) = True Then ' si coincide con la expresión que buscamos
					msgbox "comenzando teste"
					Set matches = re.Execute(registro) ' devuelve una colección de coincidencias
					For Each match In matches ' el match contiene toda la expresión regular que coincide, en este caso esperamos que sea sólo una
						msgbox match.submatches(0)
						resultado =resultado & match.SubMatches(0) & " " ' el submatches contiene sólo lo que estaba entre paréntesis
					Next 
				End If		

 	Expresion = split(resultado)
end function

Ok, I want some user input from a prompt message to use with this function, and also I want to take te returned array. Everything normal If I do like this

ips = Expresion(crt.Dialog.Prompt("Input that","IPS",vbDefaultButton),"(\d{1,3}̇\d{1,3}̇\d{1,3}̇\d{1,3}(/\d+)?)" )

Ok, marvelous, works,

But if i do like this

Code:
ips = Expresion(crt.Dialog.Prompt("Text to long for a single line so i will split this","IPS",vbDefaultButton),_
"(\d{1,3}̇\d{1,3}̇\d{1,3}̇\d{1,3}(/\d+)?)" )
The regular expression matches just white spaces.

Is this a know issue?
Reply With Quote
  #2  
Old 10-08-2012, 11:39 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi danielo515,

The issue with the code you are using doesn't appear to be specific to SecureCRT. It appears that this issue is VBScript specific. We don't track issues with VBScript, so I can't really say if this is a known issue.

I don't see a change in behavior when running either variant of your code.

Do you see the same issue if you remove SecureCRT from the picture?

For example, replace crt.Dialog.Prompt with InputBox and run the script in Windows.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 10-16-2012, 03:37 PM
danielo515 danielo515 is offline
Registered User
 
Join Date: Sep 2012
Posts: 2
Hello,

Sorry for the delay answer.

Here is a code you can test.


Code:
'Change this line to test
ips = expresion( InputBox ("Introduzca las ips como quiera que sea", "Ip's"), "(\d{1,3}̇\d{1,3}̇\d{1,3}̇\d{1,3}(/\d+)?)")

for each x in ips 
	msgbox x
next 

msgbox ubound(ips)

'===============================================
' Una forma más sencilla de intercatuar con Expresiones REGULARES 
' Recive una cadena o array de cadenas y un patrón y devuelve lo que encuentra
'===============================================

function Expresion( registro, patron )
 
dim resultado
Set re = New RegExp
re.Pattern = patron
re.Multiline = False
re.IgnoreCase = False
re.GLOBAL = TRUE
resultado = ""
 
	
 
				If re.Test(registro) = True Then ' si coincide con la expresión que buscamos
					msgbox "comenzando teste"
					Set matches = re.Execute(registro) ' devuelve una colección de coincidencias
					For Each match In matches ' el match contiene toda la expresión regular que coincide, en este caso esperamos que sea sólo una
						msgbox match.submatches(0)
						resultado =resultado & match.SubMatches(0) & " " ' el submatches contiene sólo lo que estaba entre paréntesis
					Next 
				End If		

 	Expresion = split(trim(resultado))
end function
Looks like it happens the same if you put the inputbox in the same way that i do before on secure CRT
Reply With Quote
  #4  
Old 10-17-2012, 10:37 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi danielo515,

Thanks for the update. Don't worry about the delay.

I wasn't asking you to provide me with code I can test, but I appreciate the effort. I was simply asking you if you see this issue without SecureCRT.

Since you do, this is an issue with VBScript, and assistance may be best obtained from Microsoft.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
Reply

Tags
scripting , secure crt , visual basic


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 11:23 AM.