This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular Expression