Source:
<code>public NumberSelectionResult searchNumberWithResult(String phone, Sid sourceOrganizationSid, Sid destinationOrganizationSid, Set<SearchModifier> modifiers) { if (logger.isDebugEnabled()) { logger.debug("getMostOptimalIncomingPhoneNumber: " + phone + ",srcOrg:" + sourceOrganizationSid + ",destOrg:" + destinationOrganizationSid); } List<String> numberQueries = createPhoneQuery(phone); NumberSelectionResult numberfound = findByNumber(numberQueries, sourceOrganizationSid, destinationOrganizationSid, modifiers); if (numberfound.number == null) { if (destinationOrganizationSid != null <START> && (sourceOrganizationSid == null || destinationOrganizationSid.equals(sourceOrganizationSid)) <END> && phone.matches("[\\d,*,#,+]+")) { NumberSelectionResult regexFound = findByRegex(numberQueries, sourceOrganizationSid, destinationOrganizationSid); if (regexFound.getNumber() != null) { numberfound = regexFound; } if (numberfound.number == null) { NumberSelectionResult starfound = findSingleNumber("*", sourceOrganizationSid, destinationOrganizationSid, modifiers); if (starfound.number != null) { numberfound = new NumberSelectionResult(starfound.number, false, ResultType.REGEX); } } } } return numberfound; }</code><technical_language>if provide debug messages evaluating regexes (if some condition is met), considering issues lately..</technical_language>

Target:
public NumberSelectionResult searchNumberWithResult(String phone, Sid sourceOrganizationSid, Sid destinationOrganizationSid, Set<SearchModifier> modifiers) { if (logger.isDebugEnabled()) { logger.debug("getMostOptimalIncomingPhoneNumber: " + phone + ",srcOrg:" + sourceOrganizationSid + ",destOrg:" + destinationOrganizationSid); } List<String> numberQueries = createPhoneQuery(phone); NumberSelectionResult numberfound = findByNumber(numberQueries, sourceOrganizationSid, destinationOrganizationSid, modifiers); if (numberfound.number == null) { if (destinationOrganizationSid != null && (sourceOrganizationSid == null || destinationOrganizationSid.equals(sourceOrganizationSid)) && phone.matches("[\\d,*,#,+]+")) { NumberSelectionResult regexFound = findByRegex(numberQueries, sourceOrganizationSid, destinationOrganizationSid); if (regexFound.getNumber() != null) { numberfound = regexFound; } if (numberfound.number == null) { NumberSelectionResult starfound = findSingleNumber("*", sourceOrganizationSid, destinationOrganizationSid, modifiers); if (starfound.number != null) { numberfound = new NumberSelectionResult(starfound.number, false, ResultType.REGEX); } } } } if (numberfound.number == null) { if (logger.isDebugEnabled()) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("NumberSelectionService didn't match a number because: "); if (destinationOrganizationSid == null) { stringBuffer.append(" - Destination Org is null - "); } else if (sourceOrganizationSid != null && !destinationOrganizationSid.equals(sourceOrganizationSid)) { stringBuffer.append(" - Source Org is NOT null and DOESN'T match the Destination Org - "); } else if (!phone.matches("[\\d,*,#,+]+")) { String msg = String.format(" - Phone %s doesn't match regex \"[\\\\d,*,#,+]+\" - ", phone); stringBuffer.append(msg); } else { String msg = String.format(" - Phone %s didn't match any of the Regex - ",phone); stringBuffer.append(msg); } logger.debug(stringBuffer.toString()); } } return numberfound; }