This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Regular expressions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular expressions " Watch "Regular expressions " New topic

Regular expressions

seema prakash
Ranch Hand

Joined: Nov 17, 2004
Posts: 59
I am trying to match all the possiblities using regular expressions.
When I try them individually, it works fine. But, when I try to
test it for the String test, it fails. I am not sure why this happens.
Can anyone please help ? Here is the code ...

[ December 17, 2004: Message edited by: seema prakash ]
Thomas Manthey

Joined: Dec 16, 2004
Posts: 12
why not just

[ December 17, 2004: Message edited by: Thomas Manthey ]

inside every large program there is a small program struggling to get out...
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I copied a neat trick from Martin Fowler's FitNesse Wiki ... sorry I can't point right to the doc to explain it.

I put a collection of Command objects into the expression array. Each object has a "public static final String pattern" and a "public void execute(fragment)" that knows what to do with that kind of fragment.

Lemme know if that helps!

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
seema prakash
Ranch Hand

Joined: Nov 17, 2004
Posts: 59
I am very thankful to both Thomas and Stan for the suggestions. Let me explain what I am trying to achieve. I have a word document.
I convert this into a text file. I store the contents of the text file in a string. I need to identify the subheadings such as SUMMARY in case this is a resume which has SUMMARY as one of the subheadings. Once 2 consecutive sections are identified, I will be able to process the contents in between these sections. To do that I create a regular
expression such that I can identify a section.
But, the regular expression to identify the SUMMARY section does not seem to work. I am not sure if the regular expression is right. Is this the right way I am approaching?

Here is the sample code ...

I agree. Here's the link:
subject: Regular expressions
jQuery in Action, 3rd edition