StringStartsQ

StringStartsQ["string",patt]

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

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

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

StringStartsQ[patt]

represents an operator form of StringStartsQ 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 StringStartsQ treat lowercase and uppercase letters as equivalent.
  • StringStartsQ[patt][expr] is equivalent to StringStartsQ[expr,patt].
  • StringStartsQ[BioSequence["type","seq"],patt] will check the start of the string "seq" against patt. In this case, degenerate letters in patt are interpreted as wild-card patterns based on the type of bio sequence. Use Verbatim["patt"] to match degenerate letters literally.
  • StringStartsQ has no special behavior for circular sequences, but instead interprets the start of the string as the designated start of the sequence.

Examples

open allclose all

Basic Examples  (4)

Check that a string starts with a given prefix:

Give a list of strings as input:

Specify a prefix using a string pattern:

Map the operator form over a list:

Use the operator form to select strings:

Scope  (3)

Check whether a bio sequence starts with a particular substring:

Use a wild card in the pattern compared against a bio sequence:

The "N" is a degenerate letter:

Check for literal degenerate letters using Verbatim:

Options  (1)

IgnoreCase  (1)

Match a prefix regardless of case:

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

Text

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

BibTeX

@misc{reference.wolfram_2021_stringstartsq, author="Wolfram Research", title="{StringStartsQ}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/StringStartsQ.html}", note=[Accessed: 28-September-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_stringstartsq, organization={Wolfram Research}, title={StringStartsQ}, year={2020}, url={https://reference.wolfram.com/language/ref/StringStartsQ.html}, note=[Accessed: 28-September-2021 ]}

CMS

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

APA

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