Create a java program that will accept a regular expression


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.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create a java program that will accept a regular expression
Reference No:- TGS02672123

Expected delivery within 24 Hours