Groovy GString issues

后端 未结 4 1828
后悔当初
后悔当初 2020-12-22 09:17

I\'m want use $ macro in groovy GString. When i\'m wrote this code

[\'cdata\',\'tdata\'].each { def sql = \"select * from $it_1\" }

i\'m ge

4条回答
  •  死守一世寂寞
    2020-12-22 09:47

    If the quotes are not from your IDE, or whatever you're evaluating your code in, you can do this:

    ['cdata','tdata'].each { def sql = "select * from ${it.replaceAll("'","")}_1" } 
    

提交回复
热议问题