• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regular expressions  RSS feed

 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a regular expression to split a string on every pipe symbol (|). None of my attempts are working. Here is an example of things that fail:



Any suggestions?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some characters have special meaning in regular expressions. The pipe character is an OR character I think. You can escape regex special characters with '\'. Remember that backslash is also an escape character in Java Strings so to use it in an expression you will have to escape it twice (i.e. "\\|").
[ May 22, 2007: Message edited by: Paul Sturrock ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!