1. Home
  2. Computing & Technology
  3. Python

Python Regular Expression Examples: Escaped s ('\s')

By Al Lukaszewski, About.com

Definition:
>>> import re
>>> english = '"Never increase, beyond what is necessary, the number of entities required to explain anything." -- William of Ockham (1285-1349)'
>>> print re.findall(r'.*\s', english)
['"Never increase, beyond what is necessary, the number of entities required to explain anything." -- William of Ockham ']
>>> print re.findall(r'.*?\s', english)
['"Never ', 'increase, ', 'beyond ', 'what ', 'is ', 'necessary, ', 'the ', 'number ', 'of ', 'entities ', 'required ', 'to ', 'explain ', 'anything." ', '-- ', 'William ', 'of ', 'Ockham ']

Back to the main index of this glossary

Explore Python

More from About.com

  1. Home
  2. Computing & Technology
  3. Python
  4. Regular Expressions
  5. Python RegEx Examples
  6. Escape Sequences
  7. Python RegEx - Python Regular Expressions - Examples - Escaped s ('\s')

©2008 About.com, a part of The New York Times Company.

All rights reserved.