V
V
v- death2015-12-02 15:53:40
JavaScript
v- death, 2015-12-02 15:53:40

Why does it only find the first occurrence?

test = 'текст текст<locale>текст в item</locale>текст <locale>текст</locale>';
    
        reg = test.match(/<locale>(.*?)<\/locale>/);
        reg.forEach(function(item) {
  			alert( item );
    });

Finds only "text in item"
what did I do wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2015-12-02
@vGrabko99

because read the documentation, /regexp/g

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question