Expect regular string search expression

I am trying to find a regular expression that works to match a string of escape characters (Expect answer, see this question ) and a six-digit number (with alpha-numeric first character).

Here is the whole line I need to define:

\r\n\u001b[1;14HX76196

Ultimately, I need to extract the line:

X76196 

Here is what I already have:

interact {
        #...
        #...
        #this expression does not identify the screen location
        #I need to find "\r\n\u001b[1;14H" AND "([a-zA-Z0-9]{1})[0-9]{5}$"
        #This regex was what I was using before.
        -nobuffer -re {^([a-zA-Z0-9]{1})?[0-9]{5}$} {
                set number $interact_out(0,string)
        }   

I need to identify escape characters to verify that this field is in this area of ​​the screen. So I need a regular expression that includes this first part, but the backslashes are confusing me ...

Also, as soon as I have a complete line in the variable $ number, how can I highlight only the number in another variable in Tcl?

+1
2

. , , . "-o", . .

@rikh , , , , . , , , , ( "-o" )

.

interact {
#...
    -o -nobuffer -re {(\[1;14H[a-zA-Z0-9]{1})[0-9]{5}} {
            #get number in place
            set numraw $interact_out(0,string)
            #get just number out
            set num [string range $numraw 6 11] 
            #switch to lowercase
            set num [string tolower $num]
            send_user "  stored number: $num"
    }   
}

noob Expect Tcl, , - , , .

0

, ...

[0-9]{6}

, \n - , , n, ...

\r\n\u001B\[1;14H(X[0-9]{5})
+1

Source: https://habr.com/ru/post/1727036/


All Articles