开发者

Rewrite this regexp to match only when other char is present

I have this regexp

Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}");

to match {a1|a2|a3} and {a4} format

How can I rewrite the above line, to include those matches only when a pipe | is present, so to match {a1开发者_开发问答|a2|a3} and do not match on {a4}


Add a pipe character to your regular expression:

"\\{([^\\}]+\\|[^\\}]+)\\}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜