forum

Home / DeveloperSection / Forums / how to check wheather a string has a word followed by a number or not

how to check wheather a string has a word followed by a number or not

zack mathews 1453 10-Dec-2015
I have a string like

    String test="top 10 products";
    String test2="show top 10 products";
Is there a way to check if the word "top" has a number following it. If yes get that number to another string.

I'm thinking to use indexOf("top") and add 4 to that and try to get the next word. Not sure how it will work. Any suggestions?

Updated on 10-Dec-2015

Can you answer this question?


Answer

1 Answers

Liked By