Front page | perl.beginners |
Postings from February 2010
Parsing file and regexp
Thread Next
From:
olivier.scalbert@algosyn.com
Date:
February 13, 2010 11:33
Subject:
Parsing file and regexp
Message ID:
0ad9628e-401a-4c0c-ba0d-3902ec1925f7@f34g2000yqc.googlegroups.com
Hello,
I need to extract info from some text files. And I want to do it with
Perl !
The file I need to parse has the following layout:
keywordA word1, word2, word3;
Here we can have some free text
...
...
keywordB word4,
word5, word6, word7, word8,
word9, word10;
KeywordA
word1, word2;
...
I want to extract all the "keywords" with their associated words.
For example, with this file, I would like to have:
keywordA: (word1, word2, word3)
keywordB: (word4, word5, word6, word7, word8, word9, word10)
keywordA: (word1, word2)
Is it possible to do this with regular expression ?
Or should I write a small parser ?
I have tried pattern matching with the 's' and also with the 'm'
option,
but with no good result ...
Thanks to help me !
Olivier
Thread Next
-
Parsing file and regexp
by olivier.scalbert@algosyn.com