logo
  • 教程列表
  • SO官方文檔
  • 正規表示式
    • 宣告正規表示式
    • 重複匹配字串中的模式
  1. StackOverflow 文件
  2. Scala Language 教程
  3. 正規表示式
  4. 重複匹配字串中的模式

重複匹配字串中的模式

Created: November-22, 2018

val re = """\((.*?)\)""".r

val str = "(The)(example)(of)(repeating)(pattern)(in)(a)(single)(string)(I)(had)(some)(trouble)(with)(once)"

re.findAllMatchIn(str).map(_.group(1)).toList
res2: List[String] = List(The, example, of, repeating, pattern, in, a, single, string, I, had, some, trouble, with, once)
  • 宣告正規表示式

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明