使用Java regexp查找管道内的匹配项 [英] finding matches inside pipes using java regexp

查看:88
本文介绍了使用Java regexp查找管道内的匹配项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在管道内部获取字符串的内容?

how do you get the contents of the string inside the pipe?

|qwe|asd|zxc|

我怎么获得

qwe asd zxc

我尝试过

"\\|{1,}(\\w*)\\|{1,}"

它似乎不起作用

我也尝试过

"\\|{1,}[\\w*]\\|{1,}"

它仅返回qwe

推荐答案

如果String line="|qwe|asd|zxc|";然后
使用string[] fields = line.split("\\|");
以获得所有结果的数组.

if String line="|qwe|asd|zxc|"; then
use string[] fields = line.split("\\|");
to get array of all your result..

这篇关于使用Java regexp查找管道内的匹配项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆