fix java logik to use regex