Reputation:
I have a question about expect/tcl, I expect the following
expect "class room: classroom 1"
send "classroom"
send "classroom" will return "class room: classroom 1"
but this does not match, because the expected matching become
class room: classroom 1:
how to handle the ":" in expect?
Upvotes: 1
Views: 283
Reputation: 246744
First piece of advice for developing an expect program: before you spawn
use this command
exp_internal 1
That will show you what expect sees, and you can see how it does and does not match your expected patterns.
Next, you can specify regular expressions for your patterns with expect -re {^pattern$}
. The default pattern mode is glob-style matching, which is documented in Tcl's string match command. Tcl regular expressions are documented here.
Do you want to code this:
send "classroom\r"
expect -re {class room: classroom 1:?}
Upvotes: 1
Reputation: 14391
expect will match any substring
send "hello"
expect "he"
That will match. Where is the second ":" coming from in yours?
Upvotes: 0