StringContainsQ, but anywhere in order
StringMatchQ["aabbc", "*a*c*"]
True
StringMatchQ["aabbc", "*b*a*"]
False
You can also use LongestCommonSequence
to construct a function
ClearAll[strngCntnsQ]
strngCntnsQ = LongestCommonSequence[##] == #2 &;
strngCntnsQ["aabbc", "ac"]
True
strngCntnsQ["aabbc", "ba"]
False
Is this what you need?
StringContainsQ["aabbc","a" ~~ ___ ~~ "c"]
True
The following documentation pages should help you get going with string patterns in Wolfram Language:
https://reference.wolfram.com/language/tutorial/StringPatterns.html https://reference.wolfram.com/language/tutorial/WorkingWithStringPatternsOverview.html
edit Here is a function that generalizes this idea to strings of arbitrary length:
NewStringContainsQFunction[str1_String, str2_String] :=
StringContainsQ[
str1,
StringExpression @@ Riffle[Characters[str2], ___]
]
NewStringContainsQFunction["aabbc", "ac"]
NewStringContainsQFunction["aabbc", "ba"]
NewStringContainsQFunction["aadbebfc", "abc"]
True
False
True
StringContainsQ["aaabc", RegularExpression["a.*c"]]
True