小编Vin*_*bbe的帖子

Regex.Match,startat和^(字符串的开头)

有人知道为什么这段代码的输出:

Regex re = new Regex("^bar", RegexOptions.Compiled);
string fooBarString = @"foo bar";

Match match1 = re.Match(fooBarString, 4);
Console.WriteLine(String.Format("Match 1 sucess: {0}", match1.Success));

Match match2 = re.Match(fooBarString.Substring(4));
Console.WriteLine(String.Format("Match 2 sucess: {0}", match2.Success));
Run Code Online (Sandbox Code Playgroud)

是:

比赛1成功:错误

比赛2成功:是的

预期的行为当然是"真"和"真"(否则我真的不知道"startat"参数应该对什么有用).

这个想法是这个正则表达式匹配(并且有很多它们)经常被调用(每秒几千),我们发现子串操作正在扼杀内存性能.

谢谢你的帮助!

c# regex

22
推荐指数
1
解决办法
6181
查看次数

声明管道中的Jenkins docker代理:找不到文件

尝试从https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Controlling-your-build-environment执行示例时:

pipeline {
    agent {
        docker 'node'
    }
    stages {
        stage("testing 123") {
            steps {
                sh 'node --version'
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Agent Setup)
[Pipeline] sh
[XXXXX-ABOESSRH5FV5AM3VLFMZ4UZP722N63WT5EEAE2JPIXC5U5ZTMBYA] Running shell script
+ docker pull node
Using default tag: latest
latest: Pulling from library/node
Digest: sha256:a72f8cd9aba12ea3a19ada91e077c4d8822d3bd7dc3c4707b16630e5c2477845
Status: Image is up to date for node:latest
[Pipeline] }
[Pipeline] // stage
[Pipeline] sh
[XXXXX-ABOESSRH5FV5AM3VLFMZ4UZP722N63WT5EEAE2JPIXC5U5ZTMBYA] Running shell script
+ docker inspect -f . node …
Run Code Online (Sandbox Code Playgroud)

jenkins jenkins-plugins docker jenkins-pipeline

10
推荐指数
1
解决办法
2419
查看次数

为什么HttpCookieCollection.Get在从手动实例化的对象(而不是当前的HttpContext)调用时返回null

HttpCookieCollection.Get MSDN文档中,声明:

如果指定的cookie不存在,则此方法将创建具有该名称的新cookie.

这是真的,在调用时HttpContext.Request.CookiesHttpContext.Response.Cookies从"真正的"Web服务器运行良好.

但是,这段代码:

    HttpCookieCollection foo = new HttpCookieCollection();
    HttpCookie cookie = foo.Get("foo");
    Console.WriteLine(cookie != null);
Run Code Online (Sandbox Code Playgroud)

显示False(cookie为空).

如果HttpCookieCollectionRequest.CookiesHTTP处理程序中检索,则不是这种情况.

知道这里有什么问题/是否需要任何其他设置?

我问这个是因为我在模拟HttpContextBase的地方编写单元测试,因此没有提供"真实"的上下文.

谢谢您的帮助

c# system.web httpcookiecollection

7
推荐指数
1
解决办法
3034
查看次数

Cassandra opscenter"代理无法连接"已删除的节点

我有一些EC2实例,其中cassandra配置失败.我终止了实例,机器不再存在.

Opscenter一直在唠叨这些机器上的"代理无法连接".

机器不会显示nodepool statussystem.peers表格中或表格中.

cassandra opscenter在哪里存储要连接的节点列表,所以我可以删除这些僵尸节点?

cassandra opscenter

4
推荐指数
1
解决办法
642
查看次数