charat and multiple text

I have a long string of test that i want to receive vai a  method then search all the content and every thime I find something starting <BO I want to record it and return it via a method

Anyone know how to do this.  Note I need all characters after <BO until a space is entered in the test
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yes, use indexOf.

What problems do you have writing the method?
enigma1234567890Author Commented:
how do I know when I an at end of text
enigma1234567890Author Commented:
Sorry how do I know when at end of text and how do I get multiple text analysed.  I dont want to stop when i hit the first item
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

try to use substring,

resultstring = longText.substring(longText.indexOf("
enigma1234567890Author Commented:
how do you edit the abolve code to tale all occurances of <BO
You use a cycle.

and you know that you are at the end of the text, when indexOf returns -1. Something like

int in = longText.indexOf("<BO");
while (in>0){
String startingWithBO = longText.substring(in); //do whatever you want with this one
//you might want to stop this to a > or a space - use a second parameter
longText = longText.substring(in+3);
in = longText.indexOf("<BO");


Using indexOf withput checking tends to throw exceptions :)

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
enigma1234567890Author Commented:
why do you use int in = longtxt.indexof

To find out where the next <BO starts
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.