Skip to content

[Feature request] String starts-with and ends-with #1893

@Rangi42

Description

@Rangi42

Checking whether a string has a certain prefix or suffix is a common operation, which is why even high-level programming languages have added methods for it when they already had general-purpose substring-finding. (For example, C++ added .starts_with and .ends_with to std::string in C++20, and Javascript added .startsWith and .endsWith in ECMAScript 2015.)

I commented in #1884 that ^== and $== operators would make sense, in a parallel to regex ^ and $, or CSS ^= and $=. But even if it's not a common enough need to warrant operators, functions like STRSTARTS and STRENDS would also be useful.

Compare:

Current Functions Operators
STRFIND("\1", "prefix") == 0 STRSTARTS("\1", "prefix") "\1" ^== "prefix"
STRRFIND("\1", "suffix") == STRLEN("\1") - STRLEN("suffix") STRENDS("\1", "suffix") "\1" $== "suffix"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementTypically new features; lesser priority than bugsrgbasmThis affects RGBASM

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions