How to get the last index of a substring in SQLite?

前端 未结 3 1641
猫巷女王i
猫巷女王i 2020-12-03 11:53

I have a string in the table: http://www.foo.com/hello/bar/baz and I want to get everything that comes after the last \'/\' (in this case the string \'baz\'). <

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 12:12

    There are limits to sqlite core functions' expressive power. For a known maximum number of / characters, this can be accomplished by a series of nested substr() and instr() calls, removing parts of the string to the next / at a time, but that's not too elegant.

    You should really do it in your programming language instead.

提交回复
热议问题