Java tutorial
//package com.java2s; import java.util.List; public class Main { public static boolean StdoutMatch_I2CBusDetect(String s, List<String> buslist) { String pattern_stdout_i2cbus = "(.*)([\\s\\S]*)i2c-(.*)i2c(.*)I2C(.*)adapter(.*)([\\s\\S]*)"; // i2cdetect to identify id-0, id-1, id-2, ...; if (true == matchPattern(s, pattern_stdout_i2cbus)) { String s_split[] = s.split("i2c-"); for (int i = 0; i < s_split.length; i++) { //System.out.println(s_split[i]); //s_split[] length is 4, but only 3 is useful, so jude > 0 if (s_split[i].length() > 0) { buslist.add(String.valueOf(s_split[i].charAt(0))); } } return true; } return false; } private static boolean matchPattern(String s, String pattern) { return s.matches(pattern); } }