What is the meaning of the 'g' flag in regular expressions?

前端 未结 9 823

What is the meaning of the g flag in regular expressions?

What is is the difference between /.+/g and /.+/?

9条回答
  •  醉梦人生
    2020-11-22 09:46

    Will give example based on string. If we want to remove all occurences from a string. Lets say if we want to remove all occurences of "o" with "" from "hello world"

    "hello world".replace(/o/g,'');
    

提交回复
热议问题