If I had a string like this one that has punctuation like ,, ?, ;,, what if I wanted to use string.indexOf(); to search for a string such as “like“, and get back the index?
If I remove all punctuation I could search it but because of the punctuation earlier it would give me the wrong index in the string. Is there a built-in way in Java to do such a thing? I have a workaround in mind I am going to test but won’t bother if there’s a proper way.
Yes, there is! It is called regular expressions.
Build a regex matching your punctuation and seeked substring, and search for it.
You might want to also have a look at the Matcher and Pattern classes.