regex - Extract lines selectively from blocks of lines -


please me regular expression, need components each of first meta mapping.

phrase:.\nmeta mapping*.* after this? started learning regex today.

i have far, am, kind of stuck. have document below, , output want.

main document:

phrase: "is"  phrase: "normal." meta mapping (1000):  1000   % normal (mean percent of normal) [quantitative concept] meta mapping (1000):  1000   normal [qualitative concept] meta mapping (1000):  1000   % normal (percent normal) [quantitative concept] processing 00000000.tx.8: ekg shows nonspecific changes.  phrase: "the ekg" meta mapping (1000):  1000   ekg (electrocardiogram) [finding] meta mapping (1000):  1000   ekg (electrocardiography) [diagnostic procedure]  phrase: "shows" meta mapping (1000):  1000   show [intellectual product]  phrase: "nonspecific changes." meta mapping (901):  694   nonspecific [idea or concept]  861   changes (changed status) [quantitative concept] meta mapping (901):  694   nonspecific [idea or concept]  861   changes (changing) [functional concept] meta mapping (901):  694   non-specific (unspecified) [qualitative concept]  861   changes (changed status) [quantitative concept] meta mapping (901):  694   non-specific (unspecified) [qualitative concept]  861   changes (changing) [functional concept] 

i want result have 1 meta mapping each phrase.

so

phrase: "normal." meta mapping (1000):  1000   % normal (mean percent of normal) [quantitative concept]  phrase: "the ekg" meta mapping (1000):  1000   ekg (electrocardiogram) [finding]  phrase: "shows" meta mapping (1000):  1000   show [intellectual product]  phrase: "nonspecific changes." meta mapping (901):  694   nonspecific [idea or concept]  861   changes (changed status) [quantitative concept] 

please me regular expression, need components each of first meta mapping. thank you!

i think re may work you. re, nothing awk. tested here regex101.com/

phrase.*\nmeta.*\n^((?![meta|\n]).*\n)* 

gnu awk version:

cat your_data_file | awk  ' begin {     fs="\n"     rs="\n\n"     ofs="\n" } nf > 1 {     print $1, $2     (i = 3; <= nf; i++)         if (match($i, "meta mapping")) {             print ""             next         }         else             print $i     print "" } ' 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -