>>>>> "osc" == olivier scalb...@algosyn com <olivier.scalb...@algosyn.com> 
>>>>> writes:

  osc>     keywordA word1, word2, word3;

  osc>     Here we can have some free text
  osc>     ...
  osc>     ...

  osc>     keywordB word4,
  osc>       word5, word6, word7, word8,
  osc>       word9, word10;

  osc>     KeywordA
  osc>       word1, word2;

  osc>     ...

how do you know when a keyword section begins or ends? how large is this
file? could free text have keywords? i see a ; to end a word list but
that isn't enough to properly parse this if you have 'free text'.

  osc> I want to extract all the "keywords" with their associated words.
  osc> For example, with this file, I would like to have:
  osc> keywordA: (word1, word2, word3)
  osc> keywordB: (word4, word5, word6, word7, word8, word9, word10)
  osc> keywordA: (word1, word2)

  osc> Is it possible to do this with regular expression ?
  osc> Or should I write a small parser ?

yes and yes.

  osc> I have tried pattern matching with the 's' and also with the 'm'
  osc> option,
  osc> but with no good result ...

please show your code. there is no way to help otherwise. s/// is not a
pattern matcher but a substitution operator. it uses regexes and can be
used to parse things.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to