Answer the question
In order to leave comments, you need to log in
How to compose correctly?
Condition:
The text can have 2 blocks <div>
in a row (each of them can contain any text),
but the main thing is that one should follow the other.
<div class="first">First</div><div class="second">Second</div>
<div class="first">First</div>
then it is cut out, just like if there is only a div <div class="second">Second</div>
it is cut out. Answer the question
In order to leave comments, you need to log in
/<div\s+class="first"\s*>.*<\s*\/div>\s*<div\s+class="second"\s*>.*<\s*\/div>/
>> regex = /<div\s+class="first"\s*>.*<\s*\/div>\s*<div\s+class="second"\s*>.*<\s*\/div>/
>> s = %{<div class="first">First</div><div class="second">Second</div>}
>> regex =~ s
=> 0
т.е. вхождение с 0 символа
>> s = %{<div class="second">Second</div>}
=> "<div class=\"second\">Second</div>"
>> regex =~ s
=> nil
т.е. вхождения нет
>> s = %{<div class="first">First</div>}
=> "<div class=\"first\">First</div>"
>> regex =~ s
=> nil
т.е. вхождения нет
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question