Browse - Programming Tips - How can I extract using /g in a regular expression in javaScript?

Date: 2016apr18
Language: javaScript

Q.  How can I extract using /g in a regular expression in javaScript?

A.  Here is an example:

var re = /\{([^}]*)\}/g; // {stuff}{stuff}{stuff}... var a; while ((a = re.exec(value)) !== null) { var includingBrace = a[0]; // one full match var insideBrace = a[1]; // characters inside the round brackets }
String.match() doesn't work