Java String Extract extractJobId(String line)

Here you can find the source of extractJobId(String line)

Description

extract Job Id

License

Open Source License

Declaration

public static String extractJobId(String line) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import java.util.Arrays;
import java.util.List;

public class Main {
    private static final List<Character> jobIdChars = Arrays.asList('_', '0', '1', '2', '3', '4', '5', '6', '7',
            '8', '9');

    public static String extractJobId(String line) {
        if (line.contains("job_201")) {
            int start = line.indexOf("job_201");
            int end = start;
            for (int i = start + 7; i < line.length(); i++) {
                if (jobIdChars.contains(line.charAt(i))) {
                    end = i;//from w  w w.  j av  a 2 s  .c  o  m
                } else {
                    break;
                }
            }
            String job = line.substring(start, end + 1);
            return job;
        }
        return null;
    }
}

Related

  1. extractData(String message)
  2. extractField(int position, String regex, String source)
  3. extractGenericTypeNames(String sig)
  4. extractHorizontalTabs(String line, int tabSize)
  5. extractItems(String items)
  6. extractKeyCodes(String codes)
  7. extractLines(String data, int tabWidth)
  8. extractNoPublicDomains(String domains)
  9. extractNumberFromInput(String command)