Pexpect

Cameron Simpson cs at zip.com.au
Fri Jan 6 18:00:13 EST 2017


On 06Jan2017 11:37, Joaquin Alzola <Joaquin.Alzola at lebara.com> wrote:
>Iranna Mathapati <iranna.gani28 at gmail.com> asked:
>> How to match latter(caps and small) ,numbers and # symbol in python pexpect.
>
>With a .*

Ugh. Please not. Expect() accepts a nongreedy regular expression. ".*" is the 
lazy "match absolutely anything" pattern. Generally overused and imprecise.  
Iranna Mathapati knows what to look for.

See the documentation for the re module, specificly the regular expression 
syntax:

  https://docs.python.org/3/library/re.html#regular-expression-syntax

To match letters, digits and "#", try:

  [0-9a-zA-Z#]*

Cheers,
Cameron Simpson <cs at zip.com.au>


More information about the Python-list mailing list