android - Separating the words after the last integer in a large String -


i've seen many people similar in order last word of string:

 string test =  "this sentence";  string lastword = test.substring(test.lastindexof(" ")+1); 

i similar last few words after last int, can't hard coded number , amount of words after last int unlimited. i'm wondering whether there simple way want avoid using patterns , matchers again due using them earlier on in method receive similar effect.

thanks in advance.

i last few words after last int.... number , amount of words after last int unlimited.

here's possible suggestion. using array#split

string str =  "this 1 , 2 , 3 more words .... foo bar baz"; string[] parts = str.split("\\d+(?!.*\\d)\\s+"); 

and parts[1] holds words after last number in string.

some more words .... foo bar baz 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -