Java正则表达式
大家讲道理
大家讲道理 2017-04-18 09:31:42
0
3
392

一条sql如下:select * from user where id = #{user.id}
问题:用Java字符串的replaceAll将#{user.id}替换成具体指,但是具体正则表达式怎么写?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
伊谢尔伦
sql.replaceAll("\\#\\{.*\\}", "111");

?

阿神

If you want to replace sql, just replace it directly. You can do it without regular expression. Normally, the #{user.id} that appears in your sql needs to be replaced with your variable value. If you use regular expression, the performance will be too low.

洪涛

Just splice it together

"select * from user where id = "+变量
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template