联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codehelp

您当前位置:首页 >> Java程序Java程序

日期:2020-11-06 08:26

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
0 5 7 10
Video No video submitted Video Submitted but
it does not show code,
compilation, or
testing
Video Submitted, but
only shows two of the
three requirements
(Code, Compilation,
Testing)
Video is complete
Comments None/Excessive “What” not “Why”,
few
Some “what”
comments or missing
some
Anything not obvious
has reasoning
Variable/Function
naming
Single letters
everywhere
Lots of abbreviations Full words most of the
time
Full words, descriptive
0 5 13 20
Structure Global variables
everywhere,
indentation doesn’t
match braces {}, no
helper functions
Any 2 of:
Too many Global
variables
Indentation wrong
Missing helper
functions
Any 1 of:
Too many Global
variables
Indentation wrong
Missing helper
functions
Few/no Global
variables, indentation
correct, helper
functions
State Machine Doesn’t exist Some attempt at a
state machine
Mostly correct state
machine
State machine
“perfect”
0 10 20 30
Searching Doesn’t work at all Some searches work Minor search errors All searches perfect


版权所有:留学生编程辅导网 2021,All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。