File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Help with regular expressions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with regular expressions" Watch "Help with regular expressions" New topic

Help with regular expressions

Janhavi Namshikar
Ranch Hand

Joined: Sep 29, 2005
Posts: 85

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.


"Weekends don't count unless you spend them doing something completely pointless."
Brian Cole
Ranch Hand

Joined: Sep 20, 2005
Posts: 878
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.

bitguru blog
Janhavi Namshikar
Ranch Hand

Joined: Sep 29, 2005
Posts: 85

It's an assignment for me. Othwerwise I could have easily gone for the String methods.
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456

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

Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
This site will probably be more helpful than the javadocs:
Janhavi Namshikar
Ranch Hand

Joined: Sep 29, 2005
Posts: 85

Thanks Jan and Alan.
Kevin Davies

Joined: Jun 20, 2005
Posts: 14
I agree. Here's the link:
subject: Help with regular expressions
It's not a secret anymore!