title: Extracting substring in java that ends before a certain string
body: <p>Example String:
   "Bobby is a cool person   // not really"</p>
  
  <p>I am reading from a file, and let's say I encounter the string above. I am trying to get a substring that ends just before the "//", which would yield: "Bobby is a cool person   ", (please note that in my post I intentionally put two spaces after 'person', but the editor isn't picking it up - sorry) so that I can handle it easier later. Is there any way I can combine substring method with some sort of find method in java? I am reading from files and I don't know which position the "//" might show up. Do I just have to first find the position then use substring again using that position I found with indexof? Because that would be O( n^2) which isn't ideal;</p>