code: def cmd(send, msg, args):
      if not msg:
          send("Invalid Syntax.")
          return
      char = msg[0]
      msg = [x.replace(r'\/', '/') for x in re.split(r'(?<!\\)\%s' % char, msg[1:], maxsplit=2)]
      if len(msg) == 2 and args['config']['feature'].getboolean('lazyregex'):
          msg.append('')
      if not msg or len(msg) < 3:
          send("Invalid Syntax.")
          return
      if args['type'] == 'privmsg':
          send("Don't worry, %s is not a grammar Nazi." % args['botnick'])
          return
      string = msg[0]
      replacement = msg[1]
      modifiers = get_modifiers(msg[2], args['nick'], args['config']['core']['nickregex'])
      if modifiers is None:
          send("Invalid modifiers.")
          return
      try:
          regex = re.compile(string, re.IGNORECASE) if modifiers['ignorecase'] else re.compile(string)
          log = get_log(args['db'], args['target'], modifiers['nick'])
          workers = args['handler'].workers
          result = workers.run_pool(do_replace, [log, args['config']['core'], char, regex, replacement])
          try:
              msg = result.get(5)
          except multiprocessing.TimeoutError:
              workers.restart_pool()
              send("Sed regex timed out.")
              return
          if msg:
              send(msg)
          else:
              send("No match found.")
      except sre_constants.error as ex:
          raise CommandFailedException(ex)