Skip to content

Commit 883ff18

Browse files
Merge pull request #26 from darbyluv2code/feature/make-and-expression-case-insensitive
Make AND expression case-insensitive
2 parents 672390c + c5fce6d commit 883ff18

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

  • section-04-behavioral-design-patterns/19-interpreter-v2-advanced-with-AND-expression/src/main/java/com/luv2code/designpatterns/behavioral/interpreter/v2_advanced_with_and_expression

section-04-behavioral-design-patterns/19-interpreter-v2-advanced-with-AND-expression/src/main/java/com/luv2code/designpatterns/behavioral/interpreter/v2_advanced_with_and_expression/CommandParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public Expression parse(String inputCommand) {
2020

2121
String trimmedInput = inputCommand.trim();
2222

23-
// check for AND expressions
24-
int andIndex = trimmedInput.indexOf(AND_SEPARATOR);
23+
// check for AND expressions ... ignore case
24+
int andIndex = trimmedInput.toUpperCase().indexOf(AND_SEPARATOR);
2525
if (andIndex != -1) {
2626
// we found AND
2727
String leftInput = trimmedInput.substring(0, andIndex).trim();

section-04-behavioral-design-patterns/19-interpreter-v2-advanced-with-AND-expression/src/main/java/com/luv2code/designpatterns/behavioral/interpreter/v2_advanced_with_and_expression/MainApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void main() {
1919
runCommand("/dance now", "Angel", commandParser);
2020

2121
System.out.println("\n--- Demo: Chained Commands with AND ---");
22-
runCommand("/join python-room AND /remind Customer meeting at 10am",
22+
runCommand("/join python-room And /remind Customer meeting at 10am",
2323
"Peter", commandParser);
2424

2525
}

0 commit comments

Comments
 (0)