How to write the code to find the index of "/"? - index.of ex wife

For example:
random name / other xxxx / / xxxx

I found the index of the first "/", here is what I wrote:
text.indexOf ('/')
compile it normally. pls help