coverting polynomial processing to regular expression