As I mentioned in Yet another Encoding issue..., I am writing an AI chatbot based around AI::Chat that holds a conversation in Turkish and corrects any mistakes in the Turkish supplied by the user. Of course, there are not always mistakes so a correction is not always needed.
I've promoted the AI that
"if there are no mistakes that need correcting reply with the single word "Perfect" and do not add any other words to your reply."
But being AI, it can be unpredictable! Sometimes, it will quote the Turkish and then write "Perfect" on a separate line.
Currently I check for whether there is a correction like this:
if ($reply !~ /^perfect/i) { $chatReply->{'correction'} = $reply; }
I don't want to check for "Perfect" anywhere in the reply as it might form part of a valid correction. So I am thinking of checking that "Perfect" appears either at the start of the reply or at the end like this:
if ($reply !~ /^perfect/i and $reply !~ /perfect$/i) { $chatReply->{'correction'} = $reply; }
But is there a way of combining those two regexps into just one? It seems there should be...
In reply to Regexp match start or end by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |