VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   use ReadString to match a regular expression (https://forums.vandyke.com/showthread.php?t=12892)

Hang 11-10-2017 08:34 AM

use ReadString to match a regular expression
 
Hi,

I like a script to match a regular expression to make it more universal but when I try it out, it doesn't work. I get an error saying ReadString need to match with a string.

I know the regex I have there works for what I need to match because I have tested.

Code:

# $language = "python"
# $interface = "1.0"
import re

def Main():

        p = re.compile("([\*[A|B].*\#])")
        szPrompt = p

        objTab = crt.GetScriptTab()
        objTab.Screen.Synchronous = True
        objTab.Screen.IgnoreEscape = True

        szCommand = "show card"
        objTab.Screen.Send(szCommand + "\n")

        szResult = objTab.Screen.ReadString(szPrompt)

        crt.Dialog.MessageBox(szResult)

Main()

Thanks,

ekoranyi 11-10-2017 09:18 AM

Hi Hang,

ReadString does not currently support the use of regex. You must specify a specific string to capture to. This is also true for WaitForString\s.

I have recorded your interest in our database of SecureCRT feature requests so that the product director can evaluate it for possible inclusion in a future release.

Should a version of SecureCRT become available with this feature, we will be sure to let you know.

If you would like to be contacted directly please send an email to Support@VanDyke.com with "Feature Request Forum Post 12892" in the subject line.


All times are GMT -6. The time now is 10:09 AM.