Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2113-T18-4#165 from spaceman03/bug-fix
Browse files Browse the repository at this point in the history
Bug fix: enable user input to be case insensitive
  • Loading branch information
spaceman03 authored Nov 13, 2023
2 parents eface2b + 4cd782a commit a9b3e19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/seedu/nuscents/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.regex.Pattern;

import static seedu.nuscents.commands.ListOfCommands.COMMAND_EXIT;
import static seedu.nuscents.commands.ListOfCommands.COMMAND_LIST;
Expand Down Expand Up @@ -66,7 +67,7 @@ public class Parser {
public static <TransactionList> Command parseCommand(String text, TransactionList transactions)
throws NuscentsException, ParseException {
String[] commandTypeAndArgs = text.split(" ", 2);
String commandType = commandTypeAndArgs[0];
String commandType = commandTypeAndArgs[0].toLowerCase();
String arguments;
if (commandTypeAndArgs.length > 1) {
arguments = commandTypeAndArgs[1];
Expand Down Expand Up @@ -395,13 +396,13 @@ public static EditCommand parseEdit(String arguments) throws NuscentsException,

private static String extractValue(String command, String input, String pattern, boolean isOptional)
throws NuscentsException {
java.util.regex.Pattern p = java.util.regex.Pattern.compile(pattern);
java.util.regex.Pattern p = java.util.regex.Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
java.util.regex.Matcher m = p.matcher(input);

if (m.find()) {
return m.group(1).trim();
} else if (!isOptional) {
switch (command) {
switch (command.toLowerCase()) {
case "allowance":
throw new NuscentsException(MESSAGE_EMPTY_ALLOWANCE);
case "expense":
Expand Down

0 comments on commit a9b3e19

Please sign in to comment.