How can I trim characters in Java?
e.g.
String j = “\joe\jill\”.Trim(new char[] {“\”});
j should be
"joe\jill"
String j = “jack\joe\jill\”.Trim("jack");
j should be
"\joe\jill\"
etc
How can I trim characters in Java?
e.g.
String j = “\joe\jill\”.Trim(new char[] {“\”});
j should be
"joe\jill"
String j = “jack\joe\jill\”.Trim("jack");
j should be
"\joe\jill\"
etc
I would actually write my own little function that does the trick by using plain old char access:
This behaves similar to what String.trim() does, only that it works with '\' instead of space.
Here is one alternative that works and actually uses trim(). ;) Althogh it's not very efficient it will probably beat all regexp based approaches performance wise.