Java tutorial
//package com.java2s; import java.util.*; import java.util.regex.*; public class Main { static final Matcher fpMatch = Pattern .compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?").matcher(""); /** * Scans an input string for double values. For each value found, places * in a list. This method regards any characters not part of a floating * point value to be seperators. Thus this will parse whitespace seperated, * comma seperated, and many other separation schemes correctly. */ public synchronized static double[] parseDoubleList(String list) { if (list == null) return null; fpMatch.reset(list); LinkedList<Double> doubList = new LinkedList<Double>(); while (fpMatch.find()) { String val = fpMatch.group(1); doubList.add(Double.valueOf(val)); } double[] retArr = new double[doubList.size()]; Iterator<Double> it = doubList.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = ((Double) it.next()).doubleValue(); } return retArr; } }