File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regex" Watch "Regex" New topic
Author

Regex

sahid ul karim
Greenhorn

Joined: Jun 06, 2007
Posts: 20
I have a string like :- String str="This 'is' really good work";
i want to find 'is' . What should be the regex for this ?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3527
    
  15
Do you have to use regex ? str.indexOf("'is'") will do what you want.


Joanne
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
The regex for 'is' is "'is'".
Piet Verdriet
Ranch Hand

Joined: Feb 25, 2006
Posts: 266
If it's the actual String "is" you're looking for, a simple indexOf(...) will do just fine, as already suggested.
If you want to capture text between ' (single quote), here's a way to do that:
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
That regex is more complicated than it needs to be, Piet--or at least, more advanced. The OP didn't even mention needing to extract the word from within the apostrophes, but if you really need to, using capturing groups is simpler:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regex