java - how to split a string by last underscore -
i have split string underscore. string may have many number of underscore have split last underscore. how can simple split method using regex?
you can use lastindexof
on string
returns index of last occurrence of chain of caracters.
string thing = "132131_12313_1321_312"; int index = thing.lastindexof("_"); string yourcuttedstring = thing.substring(0, index);
it returns -1
if occurrence not found in string.
Comments
Post a Comment