Create a java program that will accept a regular expression

Assignment Help JAVA Programming
Reference no: EM131876630

Assignment: Regular Expression processor in Java

Overview: Create a Java program that will accept a regular expression and a filename for a text file. The program will process the file, looking at every line to find matches for the regular expression and display them.

Regular Expression Format

The following operators are required to be accepted:

+ - one or more of the following character (no groups)
* - zero or more of the following character (no groups)
[] - no negation, no character spans - the only format is explicit, for example [0123456789]

Output:

The output from your program should be formatted like this:

Match found on line 10, starting at position 10 and ending at position 25: aaaaaaaaaaaaaa0

If the regular expression entered was a*[01]
And the input file contained at line 10:
Xxdsdsasdaaaaaaaaaaaaaaa0

Restrictions

Your program must implement its own regular expression functionality - you can not use the built-in regular expression mechanism, nor can you include one from a package or JAR file unless you created it and included the source code in your submission

Testing

Be sure to test your code thoroughly - it will be graded using regular expressions and files that you do not have access to. Your code must work for all regular expressions and text files as described above. While you MAY NOT share code in any way, I would encourage all of you to write tests and share them with each other. You can write and test your test cases against sites like : https://regex101.com/ or using Unix/Mac grep

Some Design Hints

Break this down into two problems:

1) Build a list of states from the regular expression
2) Loop over the input lines, then over each character in each input line, checking the input against the states.

I built a class to wrap String, adding the idea of which character is "current" and the ability to get the current character and to peek at the next character. This made my code cleaner and easier to reason about.

Reference no: EM131876630

Questions Cloud

Create a network security vulnerability and threat table : Create a network security vulnerability and threat table in which you outline the security architecture of organization and cryptographic means of protecting.
What is the total vehicle delay in veh-min : A new computer system is put in place at a toll booth. Assuming D/D/1 queuing, what is the total vehicle delay in veh-min?
Describe the statute in terms of all possible classification : A new state law mandates that all employers must prohibit smoking on employer premises.
What is the network diagram : What is the network diagram? Calculate the slack for each activity. Which activites are on the critical path?
Create a java program that will accept a regular expression : Create a Java program that will accept a regular expression and a filename for a text file. The program will process file, looking at every line to find matche.
Design four unique systems design diagrams from your class : Design four unique systems design diagrams from your class project for peer review. Include an old design and new design using class and architecture diagrams.
Provide basic information on industry-target market growth : Provide basic information on industry/target market growth and trends concerning your target consumer and the associated market.
Discuss your impressions of this mission statement : The founder' mission statement is about inspiring her employees to do their best on a daily basis. The mission statement also has religious references.
What does the given code segment output : What does the following code segment output? How many times will the following for-statement execute when solution is executed with the following command line?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a class diagram that shows an interface

Create a class diagram that shows an interface called Buyer in the Violet UML editor. This interface should declare the methods to perform a buyer's responsibilities

  Explain java inventory program

The file attached isn't quite what it needs to be. According to my teacher - "I need only one new feature. I don't want to include the restocking fee and item fee in the constructor.

  Write an application named us insurance

Write an application named UseInsurance that uses an abstract Insurance class and Health and Life subclasses to display different types of insurance policies and the cost per month.

  How large a value can be stored in an integer variable

Most programming languages have a built-in integer data type. Normally this representation has a fixed size, thus placing a limit on how large a value can be stored in an integer variable

  Create a java class called samearraysexception

Create a Java class called SameArraysException that extends the Exception class.

  That uses a library database of books

Write a Java program that uses a library database of books and patron data, as described in Exercise R22.2. Patrons should be able to check out and return books

  Print a space after each seat

Given numRows and numCols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat

  Calculates the area of a triangle

Write a simple Java application which calculates the area of a triangle. Your application should ask the user to enter the base and height values of the triangle.

  Implement a fishlake simulation similar to the previous

implement a fishlake simulation similar to the previous assignment. you will then make adjustments to accommodate class

  Generates n random numbers

Create a VI that generates n random numbers, where n is a user input. Display the n random numbers in an array, and in a second array display the same random umbers in ascending order.

  Implementing the tic tac toe game

Write a graphical Java program implementing the Tic Tac Toe game - The program should play against a user. The user + program should start the game on alternate games.

  What is polymorphism concept means and give an example

what this concept means and give an example to illustrate your understanding of the topic. You must use Java classes and Java interfaces to help with your description.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd