Hold program until string received

I want to have a function that holds program execution until a specific string (XX) is seen on the serial port, but, also have a timeout of 5 seconds if that string is not seen. Multiple and may be seen before the XX which is where I am having problems. Also need a return value from the function saying whether or not the string was found.

Is there something built in that I can use already or do I need to write the function from scratch?

Thanks

Is there something built in that I can use already

No.

do I need to write the function from scratch?

Yes.

There are methods in the Stream class that would give you ideas, but it's pretty simple to write your own code.

Look at the Arduino code in this demo.

...R