|
@@ -24,6 +24,30 @@ import scala.collection.mutable.ListBuffer
|
|
|
* @Description:
|
|
|
*/
|
|
|
object BaseUtil {
|
|
|
+
|
|
|
+
|
|
|
+ val url_pattern = "^((http://)|(https://))?(www\\.)?([0-9a-zA-Z\\-_\\u4e00-\\u9fa5]+(\\.[a-zA-Z\\u4e00-\\u9fa5]+){1,2}).*$".r
|
|
|
+
|
|
|
+
|
|
|
+ def trim_url_domain(url: String): String = {
|
|
|
+ if (StringUtils.isEmpty(url)) {
|
|
|
+ null
|
|
|
+ } else {
|
|
|
+ val matcher = url_pattern.pattern.matcher(url)
|
|
|
+ if (matcher.matches()) {
|
|
|
+ url_pattern replaceAllIn(url, "$5")
|
|
|
+ } else {
|
|
|
+ null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//去其他符号 去空格
|
|
|
private val pattern = "[^\\u4e00-\\u9fa50-9a-zA-Z]".r
|
|
|
|