TestKotlinReplace.kt 527 B

123456789101112131415161718192021222324
  1. package com.gxzc.zen.api
  2. import org.junit.Test
  3. import java.util.regex.Pattern
  4. /**
  5. *
  6. * @author NorthLan
  7. * @date 2018/4/29
  8. * @url https://noahlan.com
  9. */
  10. class TestKotlinReplace {
  11. @Test
  12. fun testKotlinReplace() {
  13. val url = "/user/info/{*}"
  14. val patternUrl = url.replace("\\{\\*}".toRegex(), "[a-zA-Z\\\\d]+")
  15. println("^$patternUrl\$")
  16. println(Pattern.compile("^$patternUrl\$").matcher("/user/info/1").find())
  17. println("/user/info/haha".startsWith("/user/info" + "/"))
  18. }
  19. }