Skip to content

Instantly share code, notes, and snippets.

@zfz
Last active April 1, 2016 04:16
Show Gist options
  • Save zfz/8a979d5097153ccb79d5 to your computer and use it in GitHub Desktop.
Save zfz/8a979d5097153ccb79d5 to your computer and use it in GitHub Desktop.
#http://rubular.com/r/F2OqmFF150
import re
r = """\/\*.*[^*]{0,}\*\/|\/\/.*"""
test_string = """
// my program in C++
#include <iostream>
/** playing around in
a new programming language **/
using namespace std;
int main ()
{
cout << "Hello World";
cout << "I'm a C++ program"; //use cout
return 0;
}
/*This is a program to calculate area of a circle after getting the radius as input from the user*/
#include<stdio.h>
int main()
{
double radius,area;//variables for storing radius and area
printf("Enter the radius of the circle whose area is to be calculated\n");
scanf("%lf",&radius);//entering the value for radius of the circle as float data type
area=(22.0/7.0)*pow(radius,2);//Mathematical function pow is used to calculate square of radius
printf("The area of the circle is %lf",area);//displaying the results
getch();
}
/*A test run for the program was carried out and following output was observed
If 50 is the radius of the circle whose area is to be calculated
The area of the circle is 7857.1429*/
"""
re.compile(regex).findall(test_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment