This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Regular Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regular Expression" Watch "Regular Expression" New topic

Regular Expression

Ajay Divakaran

Joined: Jul 08, 2007
Posts: 22
String s="|-|-|";

Using Pattern and Matcher in java.util.regex.* how do i write a RE
to match one or more occurance of "|-|"
Adam Nace
Ranch Hand

Joined: Jul 17, 2006
Posts: 117
What you have to watch out for is that the | has a special meaning in a regex, so you need to escape it. Furthermore, the \ has a special meaning in java, so you have to escape it. So what you should get is this:

subject: Regular Expression