pseudo regex optimization