这个正则表达式怎么写呢??

yulin001122 2007-07-16 07:43:07
这个正则表达式怎么写呢??高手请赐教一下。谢谢。

在一个字符传中把所有的[img]地址[/img]中的地址取出来。
【注意】:

1。 字符串也不一定是以[img]开始,以[/img]结束.
2。 [img]地址[/img]这样的序列可能有多个。
【举例】:
1223333[img]地址[/img]88888[img]地址1[/img]0000
我要取得地址和地址1应该怎么写呢。
...全文
174 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
joejoe1991 2007-07-16
  • 打赏
  • 举报
回复
Pattern pattern=Pattern.compile("(?<=\\[img\\]).+?(?=\\[/img\\])");

String str="1223333888880000";
Matcher matcher=pattern.matcher(str);

while(matcher.find())
{
System.out.println(matcher.group());
}
Clerk_9919 2007-07-16
  • 打赏
  • 举报
回复
String [] strs = testStr.split("([^(\\[/img\\])]*\\[img\\])|(\\[/img\\].*\\[img\\])|(\\[/img\\][^\\[img\\]]*)");

62,616

社区成员

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

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