Answer the question
In order to leave comments, you need to log in
How to make the correct regularity?
Good afternoon. For some reason, the following task is not given to me: It is
required for each g element to get the contents of the text tag, but sometimes there is a tspan tag inside this tag ..
That is, ideally here https://regex101.com/r/eAGpvp/1 at the output I have to get
1. Business center (MCC)
2. Luzhniki
But this option will do
1. Business center
2. Luzhniki
Thank you.
Answer the question
In order to leave comments, you need to log in
1.
select e.Name, d.Name
from Employee e
join Department d
on d.id = e.DepartmentId
Order by e.salary desc
Limit 1
2.
select max(d.Name), avg(e.salary) as avg_salary
from Employee e
join Department d
on d.id = e.DepartmentId
Group by d.id
Having avg_salary > 1000
if you decide not in regular expressions:
$text =<<<EOL
<g id="L-14-st-230" display="inline" opacity="1">
<text transform="matrix(1 0 0 1 226.6597 827.2749)" enable-background="new "><tspan x="0" y="0" fill="#191919" font-family="'PTSans-Regular'" font-size="16">Деловой центр</tspan><tspan x="31.6" y="14" fill="#191919" font-family="'PTSans-Regular'" font-size="16">(МЦК)</tspan></text>
</g>
<g id="L-14-st-228" display="inline" opacity="1">
<text transform="matrix(1 0 0 1 444.9458 1066.8765)" fill="#191919" font-family="'PTSans-Regular'" font-size="16">Лужники</text>
</g>
EOL;
$text = str_replace('</text>', '</text>|||', $text);
$text = strip_tags($text);
$lines = explode('|||', $text);
foreach($lines as $key => &$line)
{
$line = trim($line);
if(empty($line))
unset($lines[$key]);
}
var_dump($lines);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question