Home Page > > Details

Debug Matlab Programming|Help With Python Programming| C/C++ Programming| C/C++ Programming

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.
Here is a resource for regular expressions: https://docs.python.org/3/howto/regex.html
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]
NOTE: You do not have to implement every possible regular expression. You can limit the program to
the three symbols above.
Input:
Your program should take two command line arguments. The first should be the regular exception, the
second should be the filename.
Output:
The output from your program should be formatted exactly 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 cannot 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. Therefore, you cannot use any pattern matching
methods in any programming language.
Testing
Please be sure to test your code thoroughly. 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
Deliverables:
1) A state machine of your engine. Clearly identify each of the stages your parser can enter
2) A video recording (Either MP4 format or URL to a recording)
a. Scroll through the code
b. The code must be compiled
c. Cost must be test with at least 5 strings
3) A test plan on how you plan to test all of the regular expression options
a. Must include searching using each of the regular expression patterns
4) The test file you created to test your program
5) The Source code for your program
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.
Rubric Poor OK Good Great

Contact Us - Email:99515681@qq.com    WeChat:codinghelp
Programming Assignment Help!