File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regular expressions

 
seema prakash
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not just


[ December 17, 2004: Message edited by: Thomas Manthey ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
seema prakash
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic