if (n2[index1].isConst())
{
CVC4::String t = n2[index1].getConst<String>();
- std::size_t ret = s.find(t);
+ std::size_t ret = r == 0 ? s.find(t) : s.rfind(t);
if (ret == std::string::npos)
{
if (n1.size() == 1)
else
{
Assert(ret < s.size());
- // can strip off up to the find position
- // e.g. str.contains( str.++( "abc", x ), str.++( "b", y ) ) -->
- // str.contains( str.++( "bc", x ), str.++( "b", y ) )
+ // can strip off up to the find position, e.g.
+ // str.contains( str.++( "abc", x ), str.++( "b", y ) ) -->
+ // str.contains( str.++( "bc", x ), str.++( "b", y ) ),
+ // and
+ // str.contains( str.++( x, "abbd" ), str.++( y, "b" ) ) -->
+ // str.contains( str.++( x, "abb" ), str.++( y, "b" ) )
overlap = s.size() - ret;
}
}
--- /dev/null
+; COMMAND-LINE: --strings-exp
+; EXPECT: sat
+(set-logic QF_S)
+(declare-fun x () String)
+(declare-fun y () String)
+
+(assert (str.contains "c(ab)" (str.++ x ")")))
+(assert (str.contains "c(ab)" (str.++ "c(" y)))
+
+(declare-fun z () String)
+(declare-fun w () String)
+
+(assert (str.contains "c(ab))" (str.++ z "))")))
+(assert (str.contains z "b"))
+
+(assert (str.contains "c(ab))" (str.++ w "b)")))
+(assert (str.contains w "a"))
+
+
+(declare-fun p () String)
+(declare-fun q () String)
+
+(assert (str.contains "c(aab))" (str.++ "a" p)))
+(assert (str.contains p "a"))
+
+(assert (str.contains "c(abb))" (str.++ q "b")))
+(assert (str.contains q "b"))
+
+(check-sat)