Skip to content

string add indexOf and lastIndexOf function #135

Open

Description

@jsbxyyx

op string function

string indexOf(string str, string substr, int fromIndex)

string lastIndexOf(string str, string substr, int fromIndex)

Activity

  1. tezc commented on Mar 27, 2025

    @tezc
    Owner

    probably you can do it with strstr(), no? something like strstr(str + fromIndex, substr)

  2. jsbxyyx commented on Mar 27, 2025

    @jsbxyyx
    Author
    int indexOf(string str, string substr, int fromIndex)
    
    int lastIndexOf(string str, string substr, int fromIndex)
    

    I'm describe error. return value type is int.

  3. tezc commented on Mar 29, 2025

    @tezc
    Owner
    /* Returns a pointer to the beginning of the located substring.
       Returns NULL if the substring is not found or 'fromIndex' is larger than the length of str */
    char *sc_str_indexof(const char *str, const char *needle, uint32_t fromIndex, int reverse);

    maybe we can do something like this, similar to strstr(), it may return located string position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions