Sorry couldn't think of a better title. I'm new to Scala and I'm trying to parse out variables out of "{}". I want to be able to write regex that returns all variables out of he handle bars like example below. In some cases the sql string would have one "{}" in others it might have multiple.
val sql_str = "select * from {tbl} a left join {tbl2} b on a.id = b.id "
val r = """.*\{(.*)\}.*""".r
val result = sql_str match {
case r(value) => value
case _ => ""
}
For instance if I had the follow string:
select * from {tbl}
the result should be: tbl
for
select * from {tbl} a left join {tbl2} b on a.id = b.id
the result should be: tbl, tbl2
I tried searching for solution but couldn't find one. Thanks for any pointers you can provide.