|
|
@@ -24,10 +24,10 @@ public class AnsiPatternTest {
|
|
|
public void testMatchesString() {
|
|
|
AnsiCharSequence text = new AnsiString("Hello world 23!");
|
|
|
|
|
|
- assertTrue(AnsiPattern.compile("llo").matches(text));
|
|
|
- assertTrue(AnsiPattern.compile("23!").matches(text));
|
|
|
- assertFalse(AnsiPattern.compile(".llo").matches(text));
|
|
|
- assertFalse(AnsiPattern.compile(".23").matches(text));
|
|
|
+ assertTrue(new AnsiPattern.MSPattern("llo").matches(text));
|
|
|
+ assertTrue(new AnsiPattern.MSPattern("23!").matches(text));
|
|
|
+ assertFalse(new AnsiPattern.MSPattern(".llo").matches(text));
|
|
|
+ assertFalse(new AnsiPattern.MSPattern(".23").matches(text));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -35,27 +35,27 @@ public class AnsiPatternTest {
|
|
|
public void testMatchesRE() {
|
|
|
AnsiCharSequence text = new AnsiString("Hello world 23!");
|
|
|
|
|
|
- assertTrue( AnsiPattern.compileRE("l+o").matches(text) );
|
|
|
- assertTrue( AnsiPattern.compileRE("[0-9]+").matches(text) );
|
|
|
+ assertTrue( new AnsiPattern.REPattern("l+o").matches(text) );
|
|
|
+ assertTrue( new AnsiPattern.REPattern("[0-9]+").matches(text) );
|
|
|
|
|
|
- assertTrue( AnsiPattern.compileRE(".llo").matches(text) );
|
|
|
- assertTrue( AnsiPattern.compileRE(".23").matches(text) );
|
|
|
+ assertTrue( new AnsiPattern.REPattern(".llo").matches(text) );
|
|
|
+ assertTrue( new AnsiPattern.REPattern(".23").matches(text) );
|
|
|
|
|
|
- assertFalse( AnsiPattern.compileRE("llo\\?").matches(text) );
|
|
|
- assertFalse( AnsiPattern.compileRE("\\.23").matches(text) );
|
|
|
+ assertFalse( new AnsiPattern.REPattern("llo\\?").matches(text) );
|
|
|
+ assertFalse( new AnsiPattern.REPattern("\\.23").matches(text) );
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testFindString() {
|
|
|
AnsiCharSequence text = new AnsiString("HellTXTo TXT world TXT!");
|
|
|
|
|
|
- for(AnsiMatch item : AnsiPattern.compile("TXT").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.MSPattern("TXT").find(text)) {
|
|
|
item.value().setCharAt(1, 'E');
|
|
|
}
|
|
|
- for(AnsiMatch item : AnsiPattern.compile("TET").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.MSPattern("TET").find(text)) {
|
|
|
item.value().setCharAt(1, 'A');
|
|
|
}
|
|
|
- for(AnsiMatch item : AnsiPattern.compile("TUT").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.MSPattern("TUT").find(text)) {
|
|
|
item.value().setCharAt(1, 'Q');
|
|
|
}
|
|
|
assertEquals("HellTATo TAT world TAT!", text.toString());
|
|
|
@@ -65,13 +65,13 @@ public class AnsiPatternTest {
|
|
|
public void testFindRE() {
|
|
|
AnsiCharSequence text = new AnsiString("Hell4403o 871 world 82!");
|
|
|
|
|
|
- for(AnsiMatch item : AnsiPattern.compileRE("[0-9]+").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]+").find(text)) {
|
|
|
item.value().setCharAt(0, '$');
|
|
|
}
|
|
|
- for(AnsiMatch item : AnsiPattern.compileRE("[0-9]").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]").find(text)) {
|
|
|
item.value().setCharAt(0, '#');
|
|
|
}
|
|
|
- for(AnsiMatch item : AnsiPattern.compileRE("[0-9]").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]").find(text)) {
|
|
|
item.value().setCharAt(0, '?');
|
|
|
}
|
|
|
|
|
|
@@ -82,7 +82,7 @@ public class AnsiPatternTest {
|
|
|
public void testFindGroups() {
|
|
|
AnsiCharSequence text = new AnsiString("Hell4403o 871 world 825!");
|
|
|
|
|
|
- for(AnsiMatch item : AnsiPattern.compileRE("[0-9]([0-9]+)").find(text)) {
|
|
|
+ for(AnsiMatch item : new AnsiPattern.REPattern("[0-9]([0-9]+)").find(text)) {
|
|
|
item.group(1).setCharAt(0, '$');
|
|
|
}
|
|
|
|
|
|
@@ -95,8 +95,8 @@ public class AnsiPatternTest {
|
|
|
AnsiAttr a2 = AnsiStrings.attr(3, 4);
|
|
|
|
|
|
AnsiCharSequence text = new AnsiString("Hello world 23!");
|
|
|
- AnsiPattern.compile("o").apply(text, a1);
|
|
|
- AnsiPattern.compile("or").apply(text, a2);
|
|
|
+ new AnsiPattern.MSPattern("o").apply(text, a1);
|
|
|
+ new AnsiPattern.MSPattern("or").apply(text, a2);
|
|
|
|
|
|
AnsiCharSequence exp = new AnsiString("Hello world 23!");
|
|
|
exp.setAttr(4, 5, a1);
|
|
|
@@ -110,7 +110,7 @@ public class AnsiPatternTest {
|
|
|
AnsiAttr a1 = AnsiStrings.attr(1, 2);
|
|
|
|
|
|
AnsiCharSequence text = new AnsiString("Hello 170 world 23!");
|
|
|
- AnsiPattern.compileRE("[0-9]+").apply(text, a1);
|
|
|
+ new AnsiPattern.REPattern("[0-9]+").apply(text, a1);
|
|
|
|
|
|
AnsiCharSequence exp = new AnsiString("Hello 170 world 23!");
|
|
|
exp.setAttr(6, 9, a1);
|
|
|
@@ -123,7 +123,7 @@ public class AnsiPatternTest {
|
|
|
AnsiAttr a1 = AnsiStrings.attr(1, 2);
|
|
|
AnsiCharSequence text = new AnsiString("Hell4403o 871 world 825!");
|
|
|
|
|
|
- AnsiPattern.compileRE("[0-9]([0-9]+)").apply(text, a1);
|
|
|
+ new AnsiPattern.REPattern("[0-9]([0-9]+)").apply(text, a1);
|
|
|
|
|
|
AnsiCharSequence exp = new AnsiString("Hell4403o 871 world 825!");
|
|
|
exp.setAttr(5, 8, a1);
|