1 module cucumber.keywords; 2 3 import std..string; 4 5 struct Match { 6 string reg; 7 ulong line; 8 this(in string reg, in ulong line = __LINE__) { 9 this.reg = reg; 10 this.line = line; 11 } 12 } 13 14 alias Given = Match; 15 alias When = Match; 16 alias Then = Match; 17 alias And = Match; 18 alias But = Match; 19 20 string stripCucumberKeywords(string str) { 21 string stripImpl(string str, in string keyword) { 22 import std.array; 23 str = str.stripLeft; 24 if(str.startsWith(keyword)) { 25 return std.array.replace(str, keyword, ""); 26 } else { 27 return str; 28 } 29 } 30 31 foreach(keyword; ["Given", "When", "Then", "And", "But"]) { 32 str = stripImpl(str, keyword); 33 } 34 35 return str.stripLeft; 36 }