diff --git a/conf.d/regexroute.conf.sample b/conf.d/regexroute.conf.sample index b99b4f1e..08ebd6e3 100644 --- a/conf.d/regexroute.conf.sample +++ b/conf.d/regexroute.conf.sample @@ -43,6 +43,7 @@ ; $(ge,VAL1,VAL2) = "true" if VAL1 >= VAL2, "false" otherwise ; $(streq,VAL1,VAL2) = "true" if VAL1 = VAL2 (string), "false" otherwise ; $(strne,VAL1,VAL2) = "true" if VAL1 != VAL2 (string), "false" otherwise +; $(strpos,VAL1,VAL2) = 0-based position of VAL1 in VAL2, -1 if not found ; $(random,STRING) = STRING with each ? character replaced with a random digit ; $(index,N,ITEM1,ITEM2,...) = N-th (modulo length of list) item in list ; $(rotate,N,ITEM1,ITEM2,...) = list rotated N (modulo length of list) times diff --git a/modules/regexroute.cpp b/modules/regexroute.cpp index fb01b44f..f15186c6 100644 --- a/modules/regexroute.cpp +++ b/modules/regexroute.cpp @@ -182,6 +182,13 @@ static void evalFunc(String& str) ret ^= (str == par); str = ret; } + else if ((sep >= 0) && (str == "strpos")) { + str = par.substr(sep+1); + par = par.substr(0,sep); + vars(str); + vars(par); + str = str.find(par); + } else if ((sep >= 0) && ((str == "add") || (str == "+"))) mathOper(str,par,sep,OPER_ADD); else if ((sep >= 0) && ((str == "sub") || (str == "-")))