Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

contains a certain regular expression?

certain expression regular
0
Posted

contains a certain regular expression?

0

Assume that paragraphs are separated by blank lines. For regexes that are single terms, use the following script: sed -e ‘/./{H;$!d;}’ -e ‘x;/regex/!d’ To print paragraphs only if they contain 3 specific regular expressions (RE1, RE2, and RE3), in any order in the paragraph: sed -e ‘/./{H;$!d;}’ -e ‘x;/RE1/!d;/RE2/!d;/RE3/!d’ With this solution and the preceding one, if the paragraphs are excessively long (more than 4k in length), you may overflow sed’s internal buffers. If using HHsed, you must add a “G;” command immediately after the “x;” in the scripts above to defeat a bug in HHsed (see section 6.7.F(5), below, for a description).

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123