在Jmeter中创建正则表达式时遇到问题

时间:2018-05-16 05:08:19

标签: regex jmeter jmeter-plugins

请帮我构建以下响应序列的正则表达式

我在testplan中定义了一个变量PlanName = prod-p1。

响应:

projectmanagement.plan.Plan%3A2992173879&amp;u8=1\" ext:qtip=\"prod-p1\">prod-p1<\/a> 

正则表达式构建是:

ptc.projectmanagement.plan.Plan\%3A([^"]+)&amp\;u8=1\\" ext:qtip\=\\"${PlanName}\\">${PlanName}\<\\

目前我在Jmeter中遇到错误

jmeter.extractor.RegexExtractor: Error in pattern: ptc.projectmanagement.plan.Plan\%3A(.+?)\&amp\;u8=1\" ext:qtip\=\"prod-p1\">prod-p1\<\

3 个答案:

答案 0 :(得分:0)

您需要使用另一个反斜杠转义\符号,因此请将正则表达式修改为:

projectmanagement.plan.Plan%3(.+?)&u8=1\\" ext:qtip=\\"prod-p1\\">prod-p1</a>

演示:

JMeter Regex Demo

参考文献:

答案 1 :(得分:0)

检查以下正则表达式并输出: -

    #include <stdio.h>
    #include <iostream>
    #include <openssl/rsa.h>
    #include <openssl/pem.h>
    #include <openssl/err.h>
    #include <exception>

    bool generate_key() {
        size_t pri_len;            // Length of private key
        size_t pub_len;            // Length of public key
        char *pri_key;           // Private key in PEM
        char *pub_key;           // Public key in PEM

        int ret = 0;
        RSA *r = NULL;
        BIGNUM *bne = NULL;
        BIO *bp_public = NULL, *bp_private = NULL;
        int bits = 2048;
        unsigned long e = RSA_F4;

        EVP_PKEY *evp_pbkey = NULL;
        EVP_PKEY *evp_pkey = NULL;

        BIO *pbkeybio = NULL;
        BIO *pkeybio = NULL;

        // 1. generate rsa key
        bne = BN_new();
        ret = BN_set_word(bne, e);
        if (ret != 1) {
            goto free_all;
        }

        r = RSA_new();
        ret = RSA_generate_key_ex(r, bits, bne, NULL);
        if (ret != 1) {
            goto free_all;
        }

        // 2. save public key
        //bp_public = BIO_new_file("public.pem", "w+");
        bp_public = BIO_new(BIO_s_mem());
        ret = PEM_write_bio_RSAPublicKey(bp_public, r);
        if (ret != 1) {
            goto free_all;
        }

        // 3. save private key
        //bp_private = BIO_new_file("private.pem", "w+");
        bp_private = BIO_new(BIO_s_mem());
        ret = PEM_write_bio_RSAPrivateKey(bp_private, r, NULL, NULL, 0, NULL, NULL);

        //4. Get the keys are PEM formatted strings
        pri_len = BIO_pending(bp_private);
        pub_len = BIO_pending(bp_public);

        pri_key = (char*) malloc(pri_len + 1);
        pub_key = (char*) malloc(pub_len + 1);

        BIO_read(bp_private, pri_key, pri_len);
        BIO_read(bp_public, pub_key, pub_len);

        pri_key[pri_len] = '\0';
        pub_key[pub_len] = '\0';

        printf("\n%s\n%s\n", pri_key, pub_key);

        //verify if you are able to re-construct the keys
        pbkeybio = BIO_new_mem_buf((void*) pub_key, -1);
        if (pbkeybio == NULL) {
            return -1;
        }
        evp_pbkey = PEM_read_bio_PUBKEY(pbkeybio, &evp_pbkey, NULL, NULL);
        if (evp_pbkey == NULL) {
            char buffer[120];
            ERR_error_string(ERR_get_error(), buffer);
            printf("Error reading public key:%s\n", buffer);
        }

        pkeybio = BIO_new_mem_buf((void*) pri_key, -1);
        if (pkeybio == NULL) {
            return -1;
        }
        evp_pkey = PEM_read_bio_PrivateKey(pkeybio, &evp_pkey, NULL, NULL);
        if (evp_pbkey == NULL) {
            char buffer[120];
            ERR_error_string(ERR_get_error(), buffer);
            printf("Error reading private key:%s\n", buffer);
        }

        BIO_free(pbkeybio);
        BIO_free(pkeybio);

        // 4. free
        free_all:

        BIO_free_all(bp_public);
        BIO_free_all(bp_private);
        RSA_free(r);
        BN_free(bne);

        return (ret == 1);
    }

    int main(int argc, char* argv[]) {
        generate_key();
        return 0;
    }

enter image description here

希望它有所帮助。

答案 2 :(得分:0)

@Suraj

使用以下正则表达式

projectmanagement\.plan\.Plan%3A(.+?)&u8=1\\" ext

在你的回复中有。和\ tokens,要匹配这些字符,请附加一个反斜杠(),以便JMeter匹配该字符。或\字面。

enter image description here

了解更多信息

JMeter Regular Expressions

Extracting Variables in Jmeter

您可以使用this website来测试正则表达式