Write a c program that extract and display on the screen one or multiple pattern
ID: 3791756 • Letter: W
Question
Write a c program that extract and display on the screen one or multiple pattern (links, email addresses, phone numbers) matches from a given input file (html web page) More specifically: 45 pts Your program should accept 2 command line arguments (flag and input file). Where a flag can be one of -url I-email I-phone], and the input file should be an html file of any web page download from any "unt.edu/site page (ie, https://www.untedun.inpts Carefully design a regular expression pattern to match any 1spts o url link that match unt.edu pattern "http://housing unt.edu/content/2017-2018-housing-application-open", etc) o email address that match @unt edu pattern (ie, "urcm@unt.edu") o phone number that match "xox-xxx-xox" (i.e, "940-565-2000") e Select any Unix/Linux system program of your choice (ie, "egrep [flagn to search any given input file and return matched strings based on any of the above pattern. 5.pts In your C program, use any suitable Unix/Linux system call (ie, "e to execute a xecve") program (your selected Unix/Linux utility), along with necessary parameters (regex pattern and the input file) to accomplish the above program description. 15 pts Please see the SAMPLE OUTPUT for some example use cases. REQUIREMENTS: spts Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code. Your program should be named "minor1.c without the quotes. Your program will be graded based largely on whether it works correctly on the CSE machines (eg, cse01, cse02, cse06), so you should make sure that your program compiles and runs on a CSE machine. Please pay attention to the SAMPLE OUTPUT for how this program is expected to work. If you have any questions about this, please contact your instructor, TAs, or IA assigned to this course to ensure you understand these directions. This is an individual programming assignment that must be the sole work of the ndividual student.Explanation / Answer
#include<stdio.h>
void look_in(FILE *infile)
{
int i,j;
char substr1[100]={"*.unt.edu*"};
char substr2[100]={"*@unt.edu*"};
char substr3[12]={"%%%-%%%-%%%%"};
char str[1000];
fscanf(infile,"%[^ ]", str);
for(i=0;i<sizeof(str);i++)
{
j=0;
if(str[i]==substr1[j])
{
for(j=0;j<sizeof(substr1);j++)
printf(" ",substr1[j]);
break;
}
else if(str[i]==substr2[j])
{
for(j=0;j<sizeof(substr2);j++)
printf(" ",substr2[j] );
break;
}
else if(str[i]==substr3[j])
{
printf(" ",substr3[j]);
break;
}
else
printf("match not found");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.