Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74296

Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?

Newsgroups comp.lang.python
Date 2014-07-10 03:05 -0700
Message-ID <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> (permalink)
Subject Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]?
From rxjwg98@gmail.com

Show all headers | View raw


Hi,

On a tutorial it says that '\s': Matches whitespace. Equivalent to [\t\n\r\f].

I test it with:

>>> re.match(r'\s*\d\d*$', '   111')
<_sre.SRE_Match object at 0x03642BB8>
>>> re.match(r'\t\n\r\f*\d\d*$', '   111')    # fails
>>> re.match(r'[\t\n\r\f]*\d\d*$', '   111') # fails
>>> re.match(r'[\t\n\r\f]\d\d*$', '   111') # fails
>>> re.match(r'[\t\n\r\f]*$', '   111') # fails

What is wrong in above script? Thanks

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? rxjwg98@gmail.com - 2014-07-10 03:05 -0700
  Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? MRAB <python@mrabarnett.plus.com> - 2014-07-10 12:18 +0100
    Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? fl <rxjwg98@gmail.com> - 2014-07-10 06:32 -0700
      Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? Ned Batchelder <ned@nedbatchelder.com> - 2014-07-10 10:04 -0400
      Re: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? MRAB <python@mrabarnett.plus.com> - 2014-07-10 15:08 +0100

csiph-web