D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
st44100
Full window
Github gist
// source http://jsbin.com/kuluha
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <script id="jsbin-javascript"> var k, list, res, text, v, _i, _len; text = "\#{Key}には\#{enum1}, \#{enum2}...のどれかを入力してください"; list = { 'Key': 'aaa', 'enum1': 'bbb' }; res = text.match(/#{.*?}/g); console.log(res); for (_i = 0, _len = res.length; _i < _len; _i++) { k = res[_i]; if (!(v = list[k.replace(/#|\{|\}/g, '')])) { continue; } text = text.replace(k, v); } console.log(text, text); </script> <script id="jsbin-source-javascript" type="text/javascript">text = "\#{Key}には\#{enum1}, \#{enum2}...のどれかを入力してください" list = 'Key': 'aaa' 'enum1' : 'bbb' res =text.match(/#{.*?}/g) console.log res for k in res unless v = list[k.replace(/#|\{|\}/g, '')] then continue text = text.replace(k, v) console.log text, text </script></body> </html>