parent
19ba3644e0
commit
3da7ef8b7f
@ -0,0 +1,27 @@
|
||||
package com.wbq.zuoye;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class BVExtractor {
|
||||
public static String getBVid(String url) {
|
||||
String bv = extractBV(url);
|
||||
if (bv != null) {git
|
||||
System.out.println("Extracted BV: " + bv);
|
||||
return bv;
|
||||
} else {
|
||||
System.out.println("BV not found in the URL.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String extractBV(String url) {
|
||||
String bvPattern = "BV[0-9A-Za-z]+";
|
||||
Pattern pattern = Pattern.compile(bvPattern);
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
if (matcher.find()) {
|
||||
return matcher.group();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue