regextclexpect

The meaning of the regular expression in TCL/EXPECT


I read a tcl test script, it uses EXPECT. some of the code is:

expect ".*hello.*yes.*morning.*"

The "*" wild card is matching everything, but what about the "." in front of it? what does this mean? what kind of pattern wanted to be matched?


Solution

  • Note that the expect command's default matching style is -glob, so those dots are in fact literal dots. Help with glob-style matching can be found in the string match documentation.

    If you want your pattern to be considered as a regular expression, you have to say:

    expect -re ".*hello.*yes.*morning.*"