• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic