Created
October 15, 2013 14:38
-
-
Save christothes/6992580 to your computer and use it in GitHub Desktop.
Sample of taking some text and extracting tokens wrapped in {{ }} with regex. JSFiddle: http://jsfiddle.net/2c5LC/2/
This file contains hidden or 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 mail = "this is a mail with some {{special}} strings. Some of these {{special}} strings should be replaced with a {{someValue}}." | |
var pattern = /\{\{([\w]*)\}\}/g; | |
var match; | |
while((match = pattern.exec(mail)) !==null){ | |
console.log(match); | |
console.log('match: ' + match[0] + ' at index :' + match.index); | |
console.log('capture: ' + match[1]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment