正则表达式匹配问题

Hi,guys 我需要正则替换http { body } 的body。 下面是我的正则表达式。


    http {
            include             mime.types;
            default_type        application/octet-stream;

            log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                              '$status $body_bytes_sent "$http_referer" '
                              '"$http_user_agent" "$http_x_forwarded_for"';

            access_log  /usr/local/etc/nginx/logs/access.log  main;

            sendfile            on;

            keepalive_timeout   65;

            index index.html index.php;

            include /usr/local/etc/nginx/sites-enabled/*;

        }
    replaced=re.sub('http\s+\{([\w\W]*)\}',"http \1",config_data)

为什么1获取不到内容呢?

阅读 2.4k
1 个回答
replaced=re.sub(r'http\s+\{([\w\W]*)\}',r"http \1",config_data)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进