将管道插入Java Pattern表达式的正确方法是什么?

将管道插入Java Pattern表达式的正确方法是什么?

问题描述:

将管道插入Java模式表达式的正确方法是什么?

What is the proper way of inserting a pipe into a Java Pattern expression?

我实际上想要使用管道作为分隔符而不是或运算符。

I actually want to use a pipe as a delimiter and not the or operator.

IE:

"hello|world".split("|"); --> {"hello", "world"}


in Java 1.5 +:

in Java 1.5+:

"hello|world".split(Pattern.quote("|"));