K
K
kachi882018-09-25 21:42:07
JavaScript
kachi88, 2018-09-25 21:42:07

What is the correct way to form a regular expression?

There is an XML response from the server, you need to extract two types of response from it. I don't get a very correct answer.
What is needed is that between the info blocks and remove cdata I made such a decision. For some reason, it pulls out only the first option in a not very correct version, and then in duplicate
<info><![CDATA[Отлично]]></info>
<info><![CDATA[Все ок]]></info>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0xD34F, 2018-09-25
@kachi88

Why regular expressions? You can work with the result of a query in the same way as with a DOM tree, so your code will look a little simpler:

success(data) {
  document.querySelector('#result').innerHTML = Array
    .from(data.querySelectorAll('info'), n => `<div>${n.firstChild.nodeValue}</div>`)
    .join('');
},

M
Melkij, 2015-05-14
@Recosh

select id_item from tablename where (prop = 'naz2' and val = 2) or (prop = 'naz1' and val = 1)
group by id_item
having count(0)=2

For correct operation, a unique index on the combination of prop and val fields is required.
Or another option:
select id_item from tablename t1
join tablename t2 using(id_item)
where (t2.prop = 'naz2' and t2.val = 2) and (t1.prop = 'naz1' and t1.val = 1)

S
sbh, 2015-05-14
@sbh

Did you make the table yourself? what is the id_item column for?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question