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: 3011
9
posted
0
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
posted
0
The regex for 'is' is "'is'".
Piet Verdriet
Ranch Hand
Joined: Feb 25, 2006
Posts: 266
posted
0
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
posted
0
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: