Also with Apache StringUtils.strip() :
StringUtils.strip(null, *) = null StringUtils.strip("", *) = "" StringUtils.strip("abc", null) = "abc" StringUtils.strip(" abc", null) = "abc" StringUtils.strip("abc ", null) = "abc" StringUtils.strip(" abc ", null) = "abc" StringUtils.strip(" abcyx", "xyz") = " abc"
So,
final String SchrodingersQuotedString = "may or may not be quoted"; StringUtils.strip(SchrodingersQuotedString, "\"");
This method works with strings in quotation marks and without quotes, as shown in my example. The only drawback is that it will not look for strictly matching quotation marks, only the start and end characters of quotation marks (ie, there is no difference between "partially "fully" and "fully" quoted strings).
rath Mar 23 '16 at 14:34 2016-03-23 ββ14:34
source share