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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -