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 Regular Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular Expression" Watch "Regular Expression" New topic

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

Joined: Sep 29, 2008
Posts: 12617

What have you tried so far?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11923

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

Joined: Jul 29, 2008
Posts: 3785

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
I agree. Here's the link:
subject: Regular Expression
It's not a secret anymore!