0

Given a collection of strings which start all with prefix _abc_ABC( and end with suffix ), for instance,

val a = """_abc_ABC(
{
  x = 1
  y = 2
})"""

how to define a regular expression that strips out the prefix and suffix above ?

elm
  • 20,117
  • 14
  • 67
  • 113

1 Answers1

2

This would work:

val a = """_abc_ABC(
{
  x = 1
  y = 2
})"""

val Re = """(?s)_abc_ABC\((.*)\)""".r
a match { case Re(content) => println(content) }

The (?s) makes it match over multiple lines.

Erik van Oosten
  • 1,541
  • 14
  • 16