许家凯 2 năm trước cách đây
mục cha
commit
d174c5ee6e
1 tập tin đã thay đổi với 24 bổ sung0 xóa
  1. 24 0
      src/main/scala/com/winhc/bigdata/spark/utils/BaseUtil.scala

+ 24 - 0
src/main/scala/com/winhc/bigdata/spark/utils/BaseUtil.scala

@@ -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