I'm very happy to learn. I have not taken what parv said before badly. I know the title was wrong and I understand the reason, because I've spent a lot of time serching archives of this site for coming up with a solution to my problem.
I've serached a lot and found this:
How do I extract all text between two keywords like start and end? which is exactly what I need to do. The only problem is: I need to extract only sentences that have just three or four word between said keywords, and not match the other.
Let's say that my keywords are
atomo and
nucleo. I'd like to extract just this:
atomo/atomo/S-MS Ë/essereV-S3IP composto/comporre/V-MSPR da/da/E un/un/RIMS nucleo/nucleo/S
but not this:
atomo/atomo/S-MS non/non/B era/essereV-S3II indivisibile/indivisibile/A-NS ,/,/PU bensÏ/bensÏ/C a/a/E sua/suo/A-FS volta/volta/S-FS composto/comporre/V-MSPR da/da/E particelle/particella/S-FP pi˘/pi˘/B piccole/piccolo/A-FP (/(/PU alle/a/E-FP quali/quale/P-NP ci/ci/PQNP si/si/PQNN riferisce/riferireV-S3IP con/con/E il/il/RDMS termine/termine/S-MS "/"/PU subatomiche/subatomico/A-FP "/"/PU )/)/PU ././PU In/in/E particolare/particolare/S-MS ,/,/PU l'/lo/RDNS /atomo/atomo/S-MS Ë/essereV-S3IP composto/comporre/V-MSPR da/da/E un/un/RIMS nucleo/nucleo/S.
I managed (more or less) to do what is suggested in the link I posted before, but I don't know how to tell the regex that I don't want every single sentence that start with a keyword and end with the other, but just sentences that have three or four words between the first and the second.
I really don't know how to explain this in other words, and I'm sorry if my examples aren't clear enough. I'm a newbie and I'm italian (so my english is far from perfect).
Thanks again to everyone.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.