Write regular expressions for legal integers float in C Pyth

Write regular expressions for legal integers float (in C++, Python or Java) Write a program in Python, C++ or Java that uses regular expressions to count the number of integers and floating point numbers in an input file. Run this program on some of your own programs, and show the output. (That is, try your new program on some programs that you wrote for other courses.)

Solution

Program to count floating point numbers in input file.

import re
hand = open(\'mbox-short.txt\')
for line in hand:
    line = line.rstrip()
    x = re.findall(\'^X\\S*: ([0-9.]+)\', line)
    if len(x) > 0 :
        print x

Program to read integers -

import re
hand = open(\'mbox-short.txt\')
for line in hand:
    line = line.rstrip()
    x = re.findall(\'^[0-9.])\', line)
    if len(x) > 0 :
        print x

 Write regular expressions for legal integers float (in C++, Python or Java) Write a program in Python, C++ or Java that uses regular expressions to count the n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site