Getting a word typed

I am looking for a way to get the latest word typed that ends with a ‘.’ .
If I type


I’d like to get the word ‘page’ and not any words before. I’ve thought of something like that but it doesn’t work

         var Pos = CodeMirror.Pos;
         var cur = cm.getCursor(), token = cm.getTokenAt(cur);
         if (getTokenAt(Pos)) {....}

Can anybody help me figure it out?