This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regular Expression" Watch "Regular Expression" New topic
Author

Regular Expression

Ajay Divakaran
Greenhorn

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:

 
GeeCON Prague 2014
 
subject: Regular Expression