I'm trying to get a regular expression working, using javascript. It should match the following format, and I want to find it globaly in the following string:
[[foo=bar:something]]
foo
, bar
and something
can be any alphanumeric characters.
The expression I tried, is the following (the lots of \s*
is for matching parts with unintentional whitespaces):
var string = "something [[abc=foo:bar]] some other stuff [[foo=bar:abc]] else";
var regex = new RegExp("\\[\\[\s*.+\s*=\s*.+\s*:\s*.+\s*\\]\\]", "g");
console.log(string.match(regex));
Which gives me:
[ "[[abc=foo:bar]] some other stuff [[foo=bar:abc]]" ]
As the single match.
My question is, how could i match only this pattern, and not only the stuff between the first and last [[
and ]]
, and get this result:
[ "[[abc=foo:bar]]", "[[foo=bar:abc]]" ]