Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package logic;
- import ru.lanwen.verbalregex.VerbalExpression;
- public class Parser {
- public Parser(String in) {
- VerbalExpression replaceV = VerbalExpression.regex()
- .startOfLine()
- .then("ch")
- .then(" ")
- .capture()
- .anything()
- .endCapture()
- .then(":")
- .capture()
- .anything()
- .endCapture()
- .endOfLine()
- .build();
- VerbalExpression newV = VerbalExpression.regex()
- .startOfLine()
- .then("new")
- .then(" ")
- .capture()
- .anything()
- .endCapture()
- .endOfLine()
- .build();
- VerbalExpression removeV = VerbalExpression.regex()
- .startOfLine()
- .then("rm")
- .then(" ")
- .capture()
- .anything()
- .endCapture()
- .endOfLine()
- .build();
- if (newV.test(in)) {
- System.out.println("new command");
- } else if (replaceV.test(in)) {
- System.out.println("replace command");
- } else if (removeV.test(in)) {
- System.out.println("remove command");
- } else {
- System.out.println("invalid command");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement