/* $Id$ */
package yukihane;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* nicobrowser.util.Utilより, 必要なものをピックアップしたクラス.
+ * その後増えました.
* @author yuki
*/
-public class Util {
+public final class Util {
+
+ private Util() {
+ }
/**
* Content-Type から拡張子を決定する.
}
return contentType.split("/")[1];
}
+
+ public static String getVideoId(final String alterId) {
+ final int startIdIdx = alterId.lastIndexOf("/") + 1;
+ final String altId = alterId.substring(startIdIdx);
+ final Pattern idPattern = Pattern.compile("([a-z]*\\d+)");
+ final Matcher idMatcher = idPattern.matcher(altId);
+ if (!idMatcher.find()) {
+ throw new IllegalArgumentException("URL/IDの指定が不正です: " + alterId);
+ }
+
+ return idMatcher.group(1);
+ }
}