Separate String into two parts
<p>My <code>String</code> looks like this: <code>"/namestart blabla1 /nameend blabla2"</code>.
PS. it might also be <code>/namestartblabla1/nameendbababa2</code> for example.</p>

<p>I need to get those into two strings:</p>

<pre><code>string1 == blabla1
string2 == blabla2
</code></pre>

<p>I got my strings like this:</p>

<pre><code>if(mystring.startsWith("/namestart")){
    Pattern p = Pattern.compile("/namestart(.*?)/nameend");
    Matcher m = p.matcher(mystring);
    if (m.find()) {
      String string1 = m.group(1);
      String string2 = mystring.substring(mystring.indexOf("/nameend")+8, mystring.length()));
    }
}
</code></pre>

<p>First question is can that be done better or is this solution OK? </p>

<p>And second problem is that blabla1 and blabla2 can be anything, it can even be /nameend (probaby wont be) or something that would screw up my reg expression. What would be the theoretical solution for that?</p>
