Created
June 5, 2015 12:55
-
-
Save forcewake/82e4e646c41bb638a3db to your computer and use it in GitHub Desktop.
Getting content between curly braces in javascript regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var found = [], // an array to collect the strings that are found | |
rxp = /{([^}]+)}/g, | |
str = "a {string} with {curly} braces", | |
curMatch; | |
while( curMatch = rxp.exec( str ) ) { | |
found.push( curMatch[1] ); | |
} | |
console.log( found ); // ["string", "curly"] |
@YashashGaurav Hope by this time you found that in any case: rxp = /([^}]+)/g,
should do what you are looking for
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
["{string}", "{curly}"] - this is what I am getting as a response, I am still trying to figure out a rgx which would not include the curly braces.