0

I have an input box where a user can imput data like this:

528|438 530|438 528|439 532|439 533|438 534|438

Then I have the following RegeX, wich should put all matches in an array:

$("#offimportklik").click(function(){




            var teimporterendata = $("#importoffkader").val();
            var regex = /\d{1,3}\|\d{1,3}/;
            matches = teimporterendata.match(regex)
            alert(matches);

        })

But I only get one match every time. How do I put ALL matches in an array?

user3117628
  • 776
  • 1
  • 15
  • 35
  • You might want to read [this regex reference](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – HamZa Apr 10 '14 at 10:17

1 Answers1

3

Add /g modifier to the regex:

var regex = /\d{1,3}\|\d{1,3}/g;
raina77ow
  • 103,633
  • 15
  • 192
  • 229