小编Nit*_*olu的帖子

使用Boost替换就地正则表达式

我有一个巨大的文本段存储在名为'text'的std :: string中.在这个字符串上,我使用boost regex库用空格替换某些模式.这是我的代码.

// Remove times of the form (00:33) and (1:33)
boost::regex rgx("\\([0-9.:]*\\)");
text = boost::regex_replace(text, rgx, " ");

// Remove single word HTML tags
rgx.set_expression("<[a-zA-Z/]*>");
text = boost::regex_replace(text, rgx, " ");

// Remove comments like [pause], [laugh]
rgx.set_expression("\\[[a-zA-Z]* *[a-zA-Z]*\\]");
text = boost::regex_replace(text, rgx, " ");

// Remove comments of the form <...>
rgx.set_expression("<.+?>");
text = boost::regex_replace(text, rgx, " ");

// Remove comments of the form {...}
rgx.set_expression("\\{.+?\\}");
text = boost::regex_replace(text, rgx, " ");

// Remove comments of …
Run Code Online (Sandbox Code Playgroud)

c++ regex boost

5
推荐指数
1
解决办法
921
查看次数

Python - BaseHTTPServer 保持活动状态不起作用

我有一个基于 BaseHTTPServer 的简单服务器的以下代码。

class myHandler(BaseHTTPRequestHandler):
    #Handler for the GET requests
    def do_GET(self):
        # Parse the query_str
        query_str = self.path.strip().lower()
        if query_str.startswith("/download?"):
            query_str = query_str[10:]
            opts = urlparse.parse_qs(query_str)

            # Send the html message and download file
            self.protocol_version = 'HTTP/1.1'
            self.send_response(200)
            self.send_header("Content-type", 'text/html')
            self.send_header("Content-length", 1)
            self.end_headers()
            self.wfile.write("0")

            # Some code to do some processing
            # ...
            # -----------

            self.wfile.write("1")
Run Code Online (Sandbox Code Playgroud)

我原本期望 HTML 页面显示“1”,但它显示“0”。如何通过 keepalived 更新响应?

python basehttpserver

2
推荐指数
1
解决办法
7531
查看次数

标签 统计

basehttpserver ×1

boost ×1

c++ ×1

python ×1

regex ×1