Thank you Monks for the suggestions. They help but not fully. The problem is as follows: the sentence above itself can assume several forms. The idea is to catch the following pattern in a sentence, here is the pseudo regular expression (space is shown here as ' '): \(? \*.+?\* , \*.+?\* ... \*.+?\* , and \*.+?\* \)?
I tried to match this pattern using something like: { $line=~/\(?\s(\*.+?\*\s(\,\s)?)+and\*.+?\*\s\)?/; } but it does not work.
This pattern in a sentence can potentially appear anaywhere in a sentence, such as, start, middle, or end of sentence. Also, there can be multiple such patterns in a single sentence. For example, the pattern can appear as (a comma may or may not be present before 'and'):
*q(53)* and *s7* are related with: ( *r:72* , *p/93* , and *s8* ) , and they are also related with *s:2* , *u6* , *g78* but not *s8* . In this example I want to cluster and tag, "*q(53)* and *s7*", "*r:72* , *p/93* , and *s8*" and "*s:2* , *u6* , *g78*" together in the sentence such that the sentence will look like:
*q(53)#and#s7* are related with: *(#r:72#,#p/93#,#and#s8#)* , and they are also related with *s:2#,#u6#,#g78* but not *s8* . Please note that when there is 'but not' then only the preceding part of the pattern is selected.
Thanks very much.
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.