Created
November 11, 2013 08:33
-
-
Save otiai10/7409798 to your computer and use it in GitHub Desktop.
regex in javascript
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 re = new RegExp("\\{\\{if " + "hoge" + "\\}\\}(.*)\\{\\{\\/if\\}\\}", "g"); | |
var str = "前 {{if hoge}}ここはifの中{{/if}}あと"; | |
console.log(re.exec(str)); | |
/* | |
[ '{{if hoge}}ここはifの中{{/if}}', | |
'ここはifの中', | |
index: 2, | |
input: '前 {{if hoge}}ここはifの中{{/if}}あと' ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment