This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string.replaceall() and java.util.regex.Pattern/Matcher

 
joe nesbitt
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i have a regex that checks if the content between the 5th and 6th occurence of | is "" as follows:

(TEST\\|[||]*\\|\\|[||]*\\|[||]*\\|)\"\"")

It works fine with string.replaceall(). But when same pattern is used with java.util.regex.Pattern and Matcher classes, Matcher.find() is always false. Does it mean that the above regex must not contain the match part, I tried that but in vain.

Could someone, show me as how to use the above regex in combination of Pattern and Match classes.

Thanks in advance.
 
Rob Spoor
Sheriff
Pie
Posts: 20381
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.replaceAll uses Pattern/Matcher in the background:
In Matcher:
So if String.replaceAll is working, then you're doing something wrong when using Pattern/Matcher.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic