This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with regular expressions

 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need some help with regular expressions. I know the package java.util.regex having Pattern, Match classes, but am not sure how to use it.

What I am trying to do is this : I have to check and remove special chars like "< & ^" from a string. I have to use regular expression (regex package) for that.

Please help me out with this one.

Thanks,
Janhavi.
 
Brian Cole
Author
Ranch Hand
Posts: 902
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have to use the regex package?
Is this a homework assignment or something?

It's certainly possible to use the regex
package, but there are other ways. If the
regex package seems spooky to you, you can
do it with just the methods provided by the
String class.
 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an assignment for me. Othwerwise I could have easily gone for the String methods.
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

are you on java 5? check the javadoc of the Pattern class, it's really well-documented and straightforward...

greetings,
jan
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This site will probably be more helpful than the javadocs:

http://www.regular-expressions.info/tutorial.html
 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jan and Alan.
 
Kevin Davies
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic