Regex with first line

I want to search inside the but replacement the firsh character of line.

for example, line is this

pool 0.ubuntu.pool.ntp.org iburst maxsources 1

I want to search pool.ntp.org add firsh character # I try something but it's not work

%s/pool\.ntp\.org/#/gmi

How can I do that?


$ cat file
pool 0.ubuntu.pool.ntp.org iburst maxsources 1

$ sed -e 's/^\(.*pool\.ntp\.org\)/#\1/' file
#pool 0.ubuntu.pool.ntp.org iburst maxsources 1

explanation:

^                   # beginning of line
  \(                  # start group 1
    .*                  # 0 or more any character
    pool\.ntp\.org      # literally
  \)                  # end group

replacement:

#           # character #
\1          # backreference to group 1