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

  • 关于我们
  • 免责声明