Java String Extract extractStringsAroundDots(String s)

Here you can find the source of extractStringsAroundDots(String s)

Description

Example: "1.3" => a list that contains "1" and "3"

License

Open Source License

Declaration

private static List extractStringsAroundDots(String s) 

Method Source Code

//package com.java2s;
/*//from w ww.ja  va2s .  c  om
 * Copyright 2001-2008 Aqris Software AS. All rights reserved.
 * 
 * This program is dual-licensed under both the Common Development
 * and Distribution License ("CDDL") and the GNU General Public
 * License ("GPL"). You may elect to use one or the other of these
 * licenses.
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    /** Example: "1.3" => a list that contains "1" and "3" */
    private static List extractStringsAroundDots(String s) {
        List result = new ArrayList();
        int pos = 0;

        while (s.indexOf('.', pos) >= 0) {
            int nextPos = s.indexOf('.', pos) + 1;
            result.add(s.substring(pos, nextPos - 1));
            pos = nextPos;
        }

        result.add(s.substring(pos));

        return result;
    }
}

Related

  1. extractParameters(String uri)
  2. extractParamsFromUriTemplateFragment(String value)
  3. extractReferences(String value)
  4. extractStreetName(String address)
  5. extractStrings(String s)
  6. extractTableName(String line)
  7. extractTags(Map layoutProperties)
  8. extractUmiPositions(String pattern)
  9. extractWords(String s)