\t
is not equivalent to \s+
, but \s+
should match a tab (\t
).
The problem in your example is that the second pattern \s\s+
is looking for two or more whitespace characters, and \t
is only one whitespace character.
Here are some examples that should help you understand:
>>> result = re.match(r'\s\s+', '\t') >>> print result None >>> result = re.match(r'\s\s+', '\t\t') >>> print result <_sre.SRE_Match object at 0x10ff228b8>
\s\s+
would also match ' \t'
, '\n\t'
, ' \n \t \t\n'
.
Also, \s\s*
is equivalent to \s+
. Both will match one or more whitespace characters.
Related Posts:
- Regex: AttributeError: ‘NoneType’ object has no attribute ‘groups’
- re.sub erroring with “Expected string or bytes-like object”
- How to find all occurrences of a substring?
- Does “\d” in regex mean a digit?
- Remove all special characters, punctuation and spaces from string
- This can be done without regex:
- Remove all special characters, punctuation and spaces from string
- Extract part of a regex match
- How to remove parentheses from string [duplicate]
- TypeError: expected string or buffer
- What does this Django regular expression mean? `?P`
- Using strip() to clean up a string
- Python regex match space only
- Case insensitive regular expression without re.compile?
- python’s re: return True if string contains regex pattern
- Replace ‘ with \’ in a string
- How can I install pip on Windows?
- Best way to convert string to bytes in Python 3?
- Does Python have a string ‘contains’ substring method?
- Difference between import numpy and import numpy as np
- No module named ‘sklearn.cross_validation’
- Maximum and Minimum values for ints
- FileNotFoundError: [Errno 2] No such file or directory [duplicate]
- python capitalize first letter only
- Is there a short contains function for lists?
- ImportError: No module named pandas. Pandas installed pip
- How to Execute a Python Script in Notepad++?
- Does Python have an ordered set?
- How to count the occurrence of certain item in an ndarray?
- Python Pandas – Missing required dependencies [‘numpy’] 1
- error UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte
- No module named MySQLdb
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- pandas DataFrame “no numeric data to plot” error
- How to upgrade pip3?
- SyntaxError: multiple statements found while compiling a single statement
- Getting key with maximum value in dictionary?
- Why is the apt-get function not working in the terminal on Mac OS X v10.9 (Mavericks)?
- How do I parallelize a simple Python loop?
- TypeError: ‘str’ object cannot be interpreted as an integer [duplicate]
- Updating matplotlib in virtualenv with pip
- Is the standard Python implementation considered as a programming language or a scripting language?
- Python – from . import
- Relative paths in Python
- How to leave/exit/deactivate a Python virtualenv
- How to sort a set in python?
- How to access the ith column of a NumPy multidimensional array?
- What is a mixin, and why are they useful?
- Python equivalent to ‘hold on’ in Matlab
- What does __contains__ do, what can call __contains__ function
- Python: find position of element in array
- How to get pip to work behind a proxy server
- How to POST JSON data with Python Requests?
- Determine the type of an object?
- enumerate() for dictionary in python
- How to convert a PIL Image into a numpy array?
- How can I install Python’s pip3 on my Mac?
- Error handling in Python-MySQL
- List files ONLY in the current directory
- No Module Named ‘_pywrap_tensorflow_internal’
- Pop index out of range
- Is it possible to ignore one single specific line with Pylint?
- Print list without brackets in a single row
- Get first row value of a given column
- Python: AttributeError: ‘_io.TextIOWrapper’ object has no attribute ‘split’
- How to detect key presses?
- isPrime Function for Python Language
- Python script to copy text to clipboard
- How can I check if character in a string is a letter? (Python)
- OSError: Initializing from file failed on csv in Pandas
- What does the Ellipsis object do?
- ImportError: No module named cv2
- ./xx.py: line 1: import: command not found
- How do I run pip on python for windows?
- How to get the text cursor position in Windows?
- python NameError: global name ‘__file__’ is not defined
- Rename specific column(s) in pandas
- Issue with virtualenv – cannot activate
- Can I set max_retries for requests.request?
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- How to obfuscate Python code effectively?
- Controlling mouse with Python
- can we use XPath with BeautifulSoup?
- how to check which version of nltk, scikit learn installed?
- How do I add two sets?
- How to count the number of files in a directory using Python
- Are nested try/except blocks in Python a good programming practice?
- Getting a name error when trying to input a string [duplicate]
- Complex number troubles with numpy
- Running shell command and capturing the output
- Determine if 2 lists have the same elements, regardless of order? [duplicate]
- Python copy files to a new directory and rename if file name already exists
- How to append new data onto a new line
- Building a list inside a list in python
- Python 3 integer division [duplicate]
- numpy/scipy/ipython:Failed to interpret file as a pickle
- What is the Python equivalent of static variables inside a function?
- Python – difference between two strings
- Flask-framework: MVC pattern
- Installing win32gui python module