Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String GPS_LNG_REGULAR = "^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,5}|1[0-7]?\\d{1}\\.\\d{1,6}|180\\.0{1,6})$"; public static boolean isGpsLng(String gpsLng) { Pattern p = Pattern.compile(GPS_LNG_REGULAR); Matcher m = p.matcher(gpsLng); return m.matches(); } }