Solved D: thanks to everyone who helped me^_^
JavaScript code:
//person
string.replace(/!person/mig, function()
{
c = Math.floor((Math.random()*(Person.length-1)));
string = string.replace(/!person/mi, Person[c])
//verb
string = string.replace(/(.*?)!person/mi,function(sMatch, $1)
{
substr=$1
if (!(c==0||c==1||c==2||c==3||string.match(/!i/mi)||string.match(/!you/mi)||string.match(/!we/mi)||string.match(/!they/mi)))
substr=substr.replace(/!verbs/mgi,function()
{
b = Math.floor((Math.random()*(VerbsES.length-1)));
return VerbsES[b]})
else
substr=substr.replace(/!verbs/mgi,function()
{
b = Math.floor((Math.random()*(Verbs.length-1)));
return Verbs[b]})
return substr+"!person"
});
return string
});
//verb
string = string.replace(/!verbs/mgi,function()
{
b = Math.floor((Math.random()*(VerbsES.length-1)));
if (!(c==0||c==1||c==2||c==3||string.match(/!i/mi)||string.match(/!you/mi)||string.match(/!we/mi)||string.match(/!they/mi)))
return VerbsES[b]
else
return Verbs[b]
});