split string in to 2 based on last occurrence of a separator January 4, 2023 by Tarik Use rpartition(s). It does exactly that. You can also use rsplit(s, 1).