aspose file tools*
The moose likes Java in General and the fly likes Regular Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular Expression" Watch "Regular Expression" New topic
Author

Regular Expression

Udaya Wijenayake
Ranch Hand

Joined: May 15, 2009
Posts: 30
I have a text like this.


I want a regular expression that is match to every word related to car. Eg. Car, cars, CAR, car.


SCJP 1.5
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What have you tried so far?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11476
    
  16

do you want to match words like "Oscar" or "baccarat"? One of the tricks is that you have to first know and define what you do want, and what you don't want. A list of examples does not define that, as they don't account for all possible cases.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Udaya Wijenayake
Ranch Hand

Joined: May 15, 2009
Posts: 30
No, I want only car and cars ignoring case.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3216
    
  49

Udaya Wijenayake wrote:No, I want only car and cars ignoring case.

David Newton wrote:What have you tried so far?


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
 
jQuery in Action, 2nd edition
 
subject: Regular Expression