StringContainsQ

StringContainsQ["string",patt]

yields True if any part of string matches the string pattern patt, and yields False otherwise.

StringContainsQ[{"string1","string2",},patt]

gives a list of the results for each of the stringi.

StringContainsQ[patt]

represents an operator form of StringContainsQ that can be applied to an expression.

Details and Options

  • The string expression patt can contain any of the objects specified in the notes for StringExpression.
  • Setting the option IgnoreCase->True makes StringContainsQ treat lowercase and uppercase letters as equivalent.
  • StringContainsQ[patt][expr] is equivalent to StringContainsQ[expr,patt].
  • StringConstainsQ[BioSequence["type","seq"],patt] checks the string "seq" against patt. In this case, degenerate letters in patt are interpreted as wildcard patterns based on the type of bio sequence. Use Verbatim["patt"] to match degenerate letters literally.
  • If the bio sequence operated upon by StringContainsQ is circular, wraparound matches are possible.

Examples

open allclose all

Basic Examples  (3)

Test whether a string pattern contains a substring matching the pattern:

Give a list of strings as input:

Map an operator form over a list:

Scope  (4)

Find whether a genetic sequence contains a particular subsequence:

Bio sequences can contain sequences matching degenerate letters:

Use Verbatim to avoid finding degenerate cases:

Circular sequences support wraparound checks:

Options  (1)

IgnoreCase  (1)

Match substrings regardless of case:

Wolfram Research (2015), StringContainsQ, Wolfram Language function, https://reference.wolfram.com/language/ref/StringContainsQ.html (updated 2020).

Text

Wolfram Research (2015), StringContainsQ, Wolfram Language function, https://reference.wolfram.com/language/ref/StringContainsQ.html (updated 2020).

BibTeX

@misc{reference.wolfram_2020_stringcontainsq, author="Wolfram Research", title="{StringContainsQ}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/StringContainsQ.html}", note=[Accessed: 02-December-2020 ]}

BibLaTeX

@online{reference.wolfram_2020_stringcontainsq, organization={Wolfram Research}, title={StringContainsQ}, year={2020}, url={https://reference.wolfram.com/language/ref/StringContainsQ.html}, note=[Accessed: 02-December-2020 ]}

CMS

Wolfram Language. 2015. "StringContainsQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/StringContainsQ.html.

APA

Wolfram Language. (2015). StringContainsQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringContainsQ.html