package com.goafanti.common.utils;

import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;

public class StringUtils extends org.apache.commons.lang3.StringUtils {
	private static Pattern FRACTIONAL_NUMERIC = Pattern.compile("^[\\-+]?\\d+(\\.\\d+)?$");

	public static boolean isFractionalNumeric(String val) {
		return FRACTIONAL_NUMERIC.matcher(val).matches();
	}
	
	public static String getDomainByHttpRequest(HttpServletRequest request)
	{
		StringBuffer url = request.getRequestURL();  
		String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append(request.getServletContext().getContextPath()).append("/").toString();  
		System.out.println("\n"+tempContextUrl+"\n");
		if(tempContextUrl.contains("192")|| tempContextUrl.contains("localhost"))tempContextUrl="jishutao.com";
		return tempContextUrl;
	}
}
