StringEndsQ

StringEndsQ["string",patt]

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

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

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

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

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

StringEndsQ[patt]

represents an operator form of StringEndsQ 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 StringEndsQ treat lowercase and uppercase letters as equivalent.
  • StringEndsQ[patt][expr] is equivalent to StringEndsQ[expr,patt].
  • StringEndsQ[BioSequence["type","seq"],patt] checks the end 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.
  • StringEndsQ has no special behavior for circular biomolecular sequences, but instead interprets the end of the string as the designated end of the sequence.

Examples

open allclose all

Basic Examples  (4)

Check that a string ends with a given suffix:

Give a list of strings as input:

Specify a suffix using a string pattern:

Use the operator form of StringEndsQ:

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:

StringEndsQ automatically threads over lists of strings:

Check whether a biomolecular sequence ends in a particular substring:

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

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

Check for literal degenerate letters using Verbatim:

Options  (2)

IgnoreCase  (2)

Use IgnoreCaseTrue to check for the presence of substrings regardless of case:

The operator representation of a case-independent check:

Properties & Relations  (8)

StringEndsQ threads over lists of strings in the first argument:

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

StringStartsQ checks whether a prefix matches a pattern:

StringEndsQ checks whether a suffix matches a pattern:

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

StringEndsQ checks whether a suffix matches a pattern:

StringEndsQ returns True whenever StringMatchQ is True:

StringEndsQ["string",patt] is equivalent to StringMatchQ["string",___~~patt~~EndOfString]:

StringEndsQ["string",patt] is equivalent to StringContainsQ["string",patt~~EndOfString]:

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), StringEndsQ, Wolfram Language function, https://reference.wolfram.com/language/ref/StringEndsQ.html (updated 2020).

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_stringendsq, organization={Wolfram Research}, title={StringEndsQ}, year={2020}, url={https://reference.wolfram.com/language/ref/StringEndsQ.html}, note=[Accessed: 07-October-2024 ]}