Finding text (multiple times) and highlighting

前端 未结 4 1058
青春惊慌失措
青春惊慌失措 2020-12-03 12:44

I would like to find all the instances of a word in a Google doc and highlight them (or comment - anything so it stands out). I have created the following function, but it o

4条回答
  •  佛祖请我去吃肉
    2020-12-03 13:01

    Well, simple javascript is enough,

    var search = searchtext;
    var index = -1;
    
    while(true)
     {
       index = text.indexOf(search,index+1);
    
       if(index == -1)
         break;
       else
         /** do the required operation **/
     }
    

    Hope this helps!

提交回复
热议问题