V
V
Vladimir Golub2021-04-16 10:09:24
JavaScript
Vladimir Golub, 2021-04-16 10:09:24

How to get access to groups with the g flag?

If I remove the g flag, then there is access to groups, but only the first match. How to do this with the g flag, or just loop through the result?

let text = `
          <p>Hello world</p>
          <a href="text">Link1</a>
          <a href="text">Link2</a>
        `;
        
        const checkLinks = new RegExp('<a(.+?)>(.+?)</a>', 'g');
        
        let params = text.match(checkLinks);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Perov, 2018-07-11
@kikosko

your handler only executes once

document.addEventListener("click", (e) => {
    // Используйте e.target 
    shop.sortProductsByPrice(Product.SORT_ORDER_ASC);
    shop.show();
}, false);

If e.target === (your cell) then redraw the table and sort, then I think you'll figure it out

A
Anatoly Medvedev, 2018-07-11
@balamyt92

When you do show() you are killing priceFilter along with its event subscription. You need to re-subscribe well, or not kill him.

W
WbICHA, 2021-04-16
@RazerVG

https://developer.mozilla.org/en/docs/Web/JavaScript...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question