PhraseCache is a simple language for matching user input. A PhraseCache expression can consist of: -just a word or phrase, e.g.: school lunch time -a quoted string, e.g.: "q&a" "\o/" These strings can contain any special character. They are matched exactly character-by-character, but are case-insensitive. The pattern does not match when it's part of a bigger word (e.g. the first example would not match the input "faq&answers"). s = trim(tok_deRoundBracket(trim(s))); LS tok = javaTokWithBrackets(s); // commas (or) - "car, vehicle" LS l = tok_splitAtComma(tok); if (l(l) > 1) ret new MMOPattern.Or(lambdaMap mmo2_parsePattern(l)); // plus (and) - "give + money" l = tok_splitAtPlus(tok); if (l(l) > 1) ret new MMOPattern.And(lambdaMap mmo2_parsePattern(l)); // exclam (not) - "!something" if (startsWith(s, "!")) ret new MMOPattern.Not(mmo2_parsePattern(dropFirst(s))); -match start of line ^hello bot will match "oh hello bot", but not "hello bot friend". -match end of line please do this$ will match "now please do this", but not "please do this now". Advanced features (not really used currently): -add a weight to a sub-pattern: (foo, bar)*0.5