2 Commits

5 changed files with 36 additions and 3 deletions

View File

@@ -0,0 +1,4 @@
- (start)
// Taken from WritingWithInk.md
The Ratbear {&{wastes no time and |}swipes|scratches} {&at you|into your {&leg|arm|cheek}}.
-> start

View File

@@ -0,0 +1,12 @@
The Ratbear wastes no time and swipes at you.
The Ratbear scratches into your leg.
The Ratbear wastes no time and swipes at you.
The Ratbear scratches into your arm.
The Ratbear wastes no time and swipes at you.
The Ratbear scratches into your cheek.
The Ratbear wastes no time and swipes at you.
The Ratbear scratches into your leg.
The Ratbear wastes no time and swipes at you.
The Ratbear scratches into your arm.
The Ratbear wastes no time and swipes at you.
The Ratbear scratches into your cheek.

View File

@@ -65,10 +65,17 @@ class Util {
return false; return false;
} }
/**
Strip whichever of the given prefix list comes first at the start of a string
**/
public static function stripPrefixes(str: String, prefixes: Array<String>) { public static function stripPrefixes(str: String, prefixes: Array<String>) {
for (prefix in prefixes) { for (prefix in prefixes) {
str = StringTools.replace(str, prefix, ''); if (str.indexOf(prefix) == 0) {
str = StringTools.replace(str, prefix, '');
return StringTools.trim(str);
}
} }
return StringTools.trim(str);
return str;
} }
} }

View File

@@ -3,6 +3,6 @@ import utest.Test;
class TestMain extends Test { class TestMain extends Test {
public static function main() { public static function main() {
utest.UTest.run([new AltTest(), new StoryTest()]); utest.UTest.run([new AltTest(), new StoryTest(), new UtilTest()]);
} }
} }

10
tests/UtilTest.hx Normal file
View File

@@ -0,0 +1,10 @@
package tests;
import utest.Test;
class UtilTest extends Test {
var exampleStr1 = "here is a string {with enclosures {all nested} {up in it}}";
public function testNestedEnclosure1() {
}
}