请教一下用正则式去字符串的问题

zhuwen9 2011-04-22 04:15:58
Select * from tabA t where 1=1 and id in (slect * from tabB b wehre #[adsds])and #[t.id||t.name||t.org||t.money]

获取 #[] 之间的字符串

adsds

t.id||t.name||t.org||t.money

...全文
73 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
steryzone 2011-04-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 goldenfish1919 的回复:]
Java code

public static void main(String[] args) {
String str = "Select * from tabA t where 1=1 and id in (slect * from tabB b wehre #[adsds])and #[t.id||t.name||t.org||t.money]";
……
[/Quote]

+1
若鱼1919 2011-04-22
  • 打赏
  • 举报
回复

public static void main(String[] args) {
String str = "Select * from tabA t where 1=1 and id in (slect * from tabB b wehre #[adsds])and #[t.id||t.name||t.org||t.money]";
Matcher m = Pattern.compile("#\\[(.*?)\\]").matcher(str);
while(m.find()){
System.out.println(m.group(1));
}
}

62,634

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧