Getting a word typed

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

page.

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

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

Can anybody help me figure it out?

1 Like