If I’ve got a string that consists of other strings delimited with “/” character (xxx…xxx/xxx/xxxx) how can I get the last and the almost last (the one before last) part with t-sql? It should probably be some combination of charindex() and right().
Share
The “last one” is pretty straightforward, no explanation needed.
The “penultimate one” is essentially equal to the “last one”, with all occurrences of
@sreplaced with:which produces
'aaaaa/bbbbb/ccccc/ddddd'To check whether there are enough slashes in the string for this expression to succeed, you could do