title: How to use indexOf method on strings to extract string multiple times?
body: <p>I have 3 different strings and from each one of those I'm trying to extract specific string using <code>indexOf</code> and <code>substring</code>. However, I don't want to repeat <code>indexOf</code> so may times in the code. Is there a way I could reuse a code to extract string I want from given larger strings? Any help will be great, thank you so much!</p>
  
  <pre><code>String message1 = content1.substring(content1.indexOf(" \\\"message\\\": \\") + 1, content1.indexOf("\\\" }")).substring(15);
  String message2 = content2.substring(content2.indexOf(" \\\"message\\\": \\") + 1, content2.indexOf("\\\" }")).substring(15);
  String message3 = content3.substring(content3.indexOf(" \\\"message\\\": \\") + 1, content3.indexOf("\\\" }")).substring(15);
  </code></pre>