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

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:

I agree. Here's the link:
subject: Regular Expression
It's not a secret anymore!