there is a file with many lines, but from the file I need only a few lines. Namely questions and answers to them.

In addition, there is such a piece of code in the file.

<div itemscope itemtype="http://schema.org/Question"> <h1 itemprop="name">Какое геометрическое тело получается вращением круга вокруг своего диаметра?</h1> <h2>Варианты ответа:</h2> <div class="variants"> <div itemprop="acceptedAnswer" itemscope itemtype="http://schema.org/Answer" class="one-fourth correct"><span itemprop="text">шар</span></div> <div itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer" class="one-fourth"><span itemprop="text">цилиндр</span></div> <div itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer" class="one-fourth"><span itemprop="text">конус</span></div> <div itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer" class="one-fourth"><span itemprop="text">пирамида</span></div> </div> </div> 

How do I compose a regular expression to search in a file of strings that contain text:

  1. <h1 itemprop="name">
  2. <div itemprop="acceptedAnswer"
  3. <div itemprop="suggestedAnswer"

1 answer 1

You are correctly indicated in the comments: you should not parse html regular expressions. But if you really want:

 .*itemprop="(name|acceptedAnswer|suggestedAnswer)".* 

Here is a link to an example

  • Thank you, I have already done through the Matcher - Natalia Sergeevna