Here you can find the source of parseDouble(String s)
public static double parseDouble(String s)
//package com.java2s; //License from project: LGPL import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static Pattern nf1 = Pattern.compile("[\\-\\+]?[0-9]*\\.?[0-9]+"); private static Pattern nf2 = Pattern.compile("[\\-\\+]?\\.?[0-9]+"); /**//ww w .j ava 2s . co m * Convert to a double value */ public static double parseDouble(String s) { double rv = 0; if (s != null && s.trim().length() > 0) { try { rv = Double.parseDouble(s.trim()); } catch (NumberFormatException nfe) { boolean parsed = false; String trimmed = s.trim(); Matcher m1 = nf1.matcher(trimmed); if (m1.find()) { try { String pv = m1.group(); rv = Double.parseDouble(pv); parsed = true; } catch (NumberFormatException nfe1) { } } if (!parsed) { Matcher m2 = nf2.matcher(trimmed); if (m2.find()) { try { String pv = m1.group(); rv = Double.parseDouble(pv); parsed = true; } catch (NumberFormatException nfe2) { } } } } } return rv; } }