easy substring with java
Category None@formula is a fab thing, and some features just cant be beat, one of my faves is its
Java has the normal substring stuff, but this format is a bit of a pain (I personally hate the whole "get indexof" rigmarole to do it), but with a bit of help from regular expressions we can just use this
String Expression = ".+" + startToken + "(.+?)" + endToken + ".+";
inStr = " " + inStr + " "
return inStr.replaceAll( Expression, "$1");
}
so say we have this String
Then
handy eh?
N. B. If you want to search for any of the following characters






Comments
Posted by Mark Myers At 20:56:46 On 24/10/2010 | - Website - |
public static String substringBetween(String str,String open,
String close).
It is well documented with regard to the handling of nasty corner cases, that eat quite a bit of my time.
{ Link }
Posted by Axel At 20:56:46 On 24/10/2010 | - Website - |