
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to match anything except space and new line using Python regular expression?
The following code matches anything except space and new line in the given string using regex.
Example
import re print re.match(r'^[^ \n]*$', """IfindTutorialspointuseful""") print re.match(r'^[^ \n]*$', """I find Tutorialspointuseful""") print re.match(r'^[^ \n]*$', """Ifind Tutorialspointuseful""")
Output
This gives the output
<_sre.SRE_Match object at 0x00000000048965E0> None None
- Related Articles
- How to match tab and newline but not space using Python regular expression?
- How to match only digits in Python using Regular Expression?
- How to match a word in python using Regular Expression?
- How to match a whitespace in python using Regular Expression?
- How to match a nonwhitespace character in python using Regular Expression?
- How to match a single character in python using Regular Expression?
- How to match parentheses in Python regular expression?
- How to match any one lowercase vowel in python using Regular Expression?
- How to match digits using Java Regular Expression (RegEx)
- PHP – Match regular expression using mb_ereg_match()
- How to match at the beginning of string in python using Regular Expression?
- How to write a Python regular expression to get numbers except decimal?
- How to match non-digits using Java Regular Expression (RegEx)
- How to match nonword characters in Python using Regular Expression?\n\n\n\n
- How to match any one uppercase character in python using Regular Expression?\n\n

Advertisements