String text = "select ename from emp";
I want to know the space index after the word from. How to do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re specifically looking for the index of the first space after the word “from”, you can use:
If you’re trying to do something more general, than you’ll need to give a bit more information. But the indexOf() method will probably be very useful to you.
Edit: This should actually be
The first version returns the index relative to “from”, whereas the second returns the index relative to the original string. (thanks @jpm)
This loop will find all space characters in the given string: