• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Regular expressions

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not just


[ December 17, 2004: Message edited by: Thomas Manthey ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...

 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic