No need for special groups. Just create a regex with a space character. The space character does not have any special meaning, it just means “match a space”.
RE = re.compile(' +')
So for your case
a='rasd\nsa sd' print(re.search(' +', a))
would give
<_sre.SRE_Match object; span=(7, 8), match=' '>
Related Posts:
- whitespace in regular expression
- 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
- Case insensitive regular expression without re.compile?
- python’s re: return True if string contains regex pattern
- numpy max vs amax vs maximum
- TypeError: ‘str’ object is not callable (Python)
- ValueError: invalid literal for int() with base 10: ”
- Print string to text file
- How can I parse a YAML file in Python
- Cannot find module cv2 when using OpenCV
- Maximum and Minimum values for ints
- How is Anaconda related to Python?
- What is the python keyword “with” used for? [duplicate]
- What is the purpose of meshgrid in Python / NumPy?
- How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
- FileNotFoundError: [WinError 2] The system cannot find the file specified:
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- Importing class from another file [duplicate]
- Pandas group-by and sum
- Python List vs. Array – when to use?
- How to terminate a script?
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- csv.Error: iterator should return strings, not bytes
- SyntaxError: non-default argument follows default argument
- socket.error: [Errno 48] Address already in use
- Creating a basic auto clicker in python
- What’s the difference between torch.stack() and torch.cat() functions?
- proper name for python * operator?
- How can I flush the output of the print function?
- Python calling method in class
- No module named pkg_resources
- Opening a .ipynb.txt File
- How do I remove all packages installed by PIP?
- ValueError: need more than 1 value to unpack python
- What is the best way to exit a function (which has no return value) in python before the function ends (e.g. a check fails)?
- How to disable Python warnings?
- LinAlgError: Last 2 dimensions of the array must be square
- How to get data from SNMP with python?
- What does axis in pandas mean?
- Dynamically growing a python array when assigning to it
- “OverflowError: Python int too large to convert to C long” on windows but not mac
- Replace and overwrite instead of appending
- module ‘pandas’ has no attribute ‘rolling_mean’
- What is the grep equivalent in Python?
- Python re.split() vs split()
- Displaying better error message than “No JSON object could be decoded”
- List attributes of an object [duplicate]
- How can I set the aspect ratio in matplotlib?
- In Python how should I test if a variable is None, True or False
- Pythonic way to iterate through a range starting at 1
- Convert from CSV to array in Python
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- Relative paths in Python
- Convert bytes to int?
- Type error Unhashable type:set
- Saving a Numpy array as an image
- TypeError: ‘bool’ object is not callable
- How do I maximize the display screen in PyGame?
- Why does PyQt crashes without information? (exit code 0xC0000409)
- Python: count repeated elements in the list
- How to put the legend out of the plot
- Python string prints as [u’String’]
- How can I check the extension of a file?
- Matplotlib: TypeError: can’t multiply sequence by non-int of type ‘numpy.float64’
- NameError: global name ‘unicode’ is not defined – in Python 3
- Create nice column output in python
- TypeError: unsupported operand type(s) for +=: ‘int’ and ‘list’
- TypeError: int() argument must be a string, a bytes-like object or a number, not ‘list’
- Histogram plotting “AttributeError: max must be larger than min in range parameter.”
- Python TypeError: non-empty format string passed to object.__format__
- AttributeError: ‘Series’ object has no attribute ‘reshape’
- “This constructor takes no arguments” error in __init__
- plot a circle with pyplot
- TypeError: super() takes at least 1 argument (0 given) error is specific to any python version?
- ValueError: cannot switch from manual field specification to automatic field numbering
- TemplateDoesNotExist at /
- How do I update a Python package?
- How can I count time in Python 3?
- OpenCV houghLinesP parameters
- Generate a random letter in Python
- NameError from Python input() function
- How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?
- Syntax highlighting in vim for python
- How do I restart a program based on user input?
- Python Pandas : pivot table with aggfunc = count unique distinct
- Flask Value error view function did not return a response [duplicate]
- AttributeError: ‘Series’ object has no attribute ‘split’ error in sending emails