2024-04-19 09:46:54 +08:00
|
|
|
package com.coloryr.allmusic.server.core.utils;
|
2020-02-20 23:49:25 +08:00
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
2020-02-21 01:31:50 +08:00
|
|
|
public class Function {
|
2020-02-20 23:49:25 +08:00
|
|
|
public static boolean isInteger(String str) {
|
2024-04-18 09:03:23 +08:00
|
|
|
Pattern pattern = Pattern.compile("^[-+]?\\d*$");
|
2020-02-20 23:49:25 +08:00
|
|
|
return pattern.matcher(str).matches();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getString(String a, String b, String c) {
|
|
|
|
|
int x = a.indexOf(b) + b.length();
|
|
|
|
|
int y;
|
|
|
|
|
if (c != null)
|
|
|
|
|
y = a.indexOf(c);
|
|
|
|
|
else y = a.length();
|
2020-02-21 01:31:50 +08:00
|
|
|
if (x < 0 || y < 0)
|
|
|
|
|
return a;
|
2020-02-20 23:49:25 +08:00
|
|
|
return a.substring(x, y);
|
|
|
|
|
}
|
2020-02-21 01:31:50 +08:00
|
|
|
|
|
|
|
|
public static int countChar(String a, char b) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (char t : a.toCharArray()) {
|
|
|
|
|
if (t == b)
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
return count;
|
|
|
|
|
}
|
2020-02-20 23:49:25 +08:00
|
|
|
}
|