Refactor StringUtil.extractFirst and extractLast methods (with tests)

Discovered while fixing this: http://ci.liferay.org.es/jenkins/job/mdelapenya/579/testReport/com.liferay.portlet.documentlibrary.service/DLFileVersionTest/testUpdateDescription