Last active
August 29, 2015 13:56
-
-
Save tarunon/8936778 to your computer and use it in GitHub Desktop.
短文の末尾に(某)を付けるためのスクリプト。
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 mScript = function(text) { | |
// 正規表現パターンで付加する文字を決定する。 | |
var regs = { | |
"命令懇願": /[えけげせぜてでねへべぺめれ]よ?[。.]?$/, | |
"疑問惑困": /[??]$/, | |
"嬉輝喜怒哀楽": /[!!]$/, | |
"困惑": /[えけげせぜてでねへべぺめれ][んぬ][。.]?$/, | |
"飛旅": /旅行/, | |
"期待輝余裕勃": /.*/ | |
}; | |
// 正規表現に一致したらkeyからランダムに1文字追加。 | |
for (var key in regs) { | |
if(text.match(regs[key])) { | |
text += '(' + key.charAt(key.length * Math.random()) + ')'; | |
break; | |
} | |
} | |
return text; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment