Skip to content

Commit

Permalink
Merge pull request #39 from myjian/master
Browse files Browse the repository at this point in the history
Ensure removeModifier method turns off the flags
  • Loading branch information
lanwen committed Oct 22, 2015
2 parents 822907f + c2f9b59 commit eaa962e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/main/java/ru/lanwen/verbalregex/VerbalExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,25 +397,25 @@ public Builder addModifier(final char pModifier) {
public Builder removeModifier(final char pModifier) {
switch (pModifier) {
case 'd':
modifiers ^= Pattern.UNIX_LINES;
modifiers &= ~Pattern.UNIX_LINES;
break;
case 'i':
modifiers ^= Pattern.CASE_INSENSITIVE;
modifiers &= ~Pattern.CASE_INSENSITIVE;
break;
case 'x':
modifiers ^= Pattern.COMMENTS;
modifiers &= ~Pattern.COMMENTS;
break;
case 'm':
modifiers ^= Pattern.MULTILINE;
modifiers &= ~Pattern.MULTILINE;
break;
case 's':
modifiers ^= Pattern.DOTALL;
modifiers &= ~Pattern.DOTALL;
break;
case 'u':
modifiers ^= Pattern.UNICODE_CASE;
modifiers &= ~Pattern.UNICODE_CASE;
break;
case 'U':
modifiers ^= Pattern.UNICODE_CHARACTER_CLASS;
modifiers &= ~Pattern.UNICODE_CHARACTER_CLASS;
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void testWithAnyCase() {
}

@Test
public void testWithAnyCaseIsFalse() {
public void testWithAnyCaseTurnOnThenTurnOff() {
VerbalExpression testRegex = regex()
.withAnyCase()
.startOfLine()
Expand All @@ -311,6 +311,17 @@ public void testWithAnyCaseIsFalse() {
assertThat(testRegex, not(matchesTo("A")));
}

@Test
public void testWithAnyCaseIsFalse() {
VerbalExpression testRegex = regex()
.startOfLine()
.then("a")
.withAnyCase(false)
.build();

assertThat(testRegex, not(matchesTo("A")));
}

@Test
public void testSearchOneLine() {
VerbalExpression testRegex = regex()
Expand Down Expand Up @@ -595,4 +606,4 @@ public void shouldAddMaybeWithOneOfFromAnotherBuilder() {
assertThat("Is a name without prefix", name, matchesTo("James"));

}
}
}

0 comments on commit eaa962e

Please sign in to comment.