StringStartsQ

StringStartsQ["string",patt]

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

StringStartsQ["string",{patt1,patt2,}]

yields True if the beginning of "string" matches any of the patti.

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] checks the start of the string "seq" against patt. In this case, degenerate letters in patt are interpreted as wildcard patterns based on the type of biomolecular sequence. Use Verbatim["patt"] to match degenerate letters literally.
  • The documentation for BioSequence lists the degenerate letters supported by each type of biomolecular sequence.
  • StringStartsQ has no special behavior for circular biomolecular 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:

Use the operator form of StringStartsQ:

Use the operator form to select strings:

Scope  (9)

Use string patterns:

Use a regular expression:

Mix regular expressions and string patterns:

Use pattern matching for dates:

Test for occurrences of either pattern:

StringStartsQ automatically threads over lists of strings:

Check whether a biomolecular sequence starts with a particular substring:

Use a wildcard in the pattern compared against a biomolecular sequence:

The "N" is a degenerate letter only in biomolecular sequences:

Check for literal degenerate letters using Verbatim:

Options  (2)

IgnoreCase  (2)

Use IgnoreCaseTrue to check for a leading string regardless of case:

The operator representation of a case-independent check:

Properties & Relations  (8)

StringStartsQ threads over lists of strings in the first argument:

StringStartsQ["string",{patt1,patt2,}] is equivalent to StringStartsQ["string",Alternatives[patt1,patt2,]]:

StringEndsQ checks whether a suffix matches a pattern:

StringStartsQ checks whether a prefix matches a pattern:

Use StringMatchQ to check whether a whole string matches a pattern:

StringStartsQ checks whether a prefix matches a pattern:

StringStartsQ returns True whenever StringMatchQ is True:

StringStartsQ["string",patt] is equivalent to StringMatchQ["string",StartOfString~~patt~~___]:

StringStartsQ["string",patt] is equivalent to StringContainsQ["string",StartOfString~~patt]:

Get the starting and ending positions where a prefix occurs by using StringPosition:

Use StringCases to extract prefixes matching a given pattern:

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).

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

BibTeX

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

BibLaTeX

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