- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write a Python regular expression that matches floating point numbers?
The following code uses Python regex to match floating point numbers
import re s = '234.6789' match = re.match(r'[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?',s) print match.group() s2 = '0.45' match = re.match(r'[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?',s2) print match.group()
This gives the output
- How to write a Python Regular Expression to validate numbers?
- How to write a Python regular expression to get numbers except decimal?
- Write a one line C function to round floating point numbers
- Signed floating point numbers
- How can I find all matches to a regular expression in Python?
- How to write a Python regular expression to use re.findall()?
- How to extract floating number from text using Python regular expression?
- Regular expression matches multiple lines in Java
- How to write a case insensitive Python regular expression without re.compile?
- How to write Python regular expression to check alphanumeric characters?
- How to write a Python regular expression to match multiple words anywhere?
- How to write Python Regular Expression find repeating digits in a number?
- How to write Python regular expression to match with file extension?
- Java program to multiply given floating point numbers