• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pcre_get_substring函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pcre_get_substring函数的典型用法代码示例。如果您正苦于以下问题:C++ pcre_get_substring函数的具体用法?C++ pcre_get_substring怎么用?C++ pcre_get_substring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pcre_get_substring函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Download_file

void TGielda::Refresh_data_onet()
{
	/* FIXME: jesli spolka, umarla ( jej cena to --- ) to nie zostanie
	 * to sparsowane poprawnie i pominieta zostanie kolejna spolka
	 * now blad - onet chyba teraz pokazuje cene w "[]", trzeba poprawic regexp
	 */
	char* bufor = NULL;
	pcre* re;
	const char* error = NULL;
	int erroffset;
	int index = 0;
	int rc;
	const int OVECCOUNT = 30;
	int ovector[OVECCOUNT];
	char* pozycja;

	bufor = Download_file(curl, "http://gielda.onet.pl/indeksy-i-akcje,18633,100,0,notowania-gpw-start");
	my_companies.clear();
	my_companies.reserve(512);
	do
	{
		re = pcre_compile("<div class=\"name2\"><a.*?>(.*?)<.*?raitings.*?>\\s*?\\[?([-0-9, ]+)\\]?\\s*?<.*?raitings.*?>\\s*?\\[?([-0-9,]+)\\]?\\s*?<",
		PCRE_DOTALL, &error, &erroffset, NULL);
		rc = pcre_exec(re, NULL, bufor + index, strlen(bufor + index), 0, 0, ovector,
			OVECCOUNT);
		if (rc == PCRE_ERROR_NOMATCH)
			break;
		if (rc < 0)
			break;
		if (rc == 0)
			puts("za malo miejsca w buforze");
		
		char* name;
		char* price;
		char* day_delta;
		pcre_get_substring(bufor + index, ovector, rc, 1, (const char** )&name);
		pcre_get_substring(bufor + index, ovector, rc, 2, (const char** )&price);
		pcre_get_substring(bufor + index, ovector, rc, 3, (const char** )&day_delta);
		
		if ((pozycja = strchr(day_delta, ',')))
			*pozycja = '.';
		if ((pozycja = strchr(price, ',')))
			*pozycja = '.';
		char* price_replaced = Replace_all(price, " ", "");
		
		TSpolka spolka(name,
			price_replaced ? price_replaced : price,
			day_delta, "", "", "", "", "");
		my_companies.push_back(spolka);

		pcre_free_substring(name);
		pcre_free_substring(price);
		pcre_free_substring(day_delta);

		 index += ovector[1];
	}
	while (true);
	my_last_update = time(NULL);
	delete[] bufor;
}
开发者ID:mszacun,项目名称:Paseczek,代码行数:60,代码来源:gielda.cpp


示例2: DetectPayloadLenFieldParse

static int DetectPayloadLenFieldParse(DetectPayloadLenFieldData *dt, const char * sig) {
	char *args[3] = {NULL,NULL,NULL};
	#define MAX_SUBSTRINGS 30
	int ret = 0, res = 0;
	int ov[MAX_SUBSTRINGS];

	dt->offset = 0;

	ret = pcre_exec(parse_regex, parse_regex_study, sig, strlen(sig), 0, 0, ov, MAX_SUBSTRINGS);
	if (ret < 3) goto error;

	const char *str_ptr;
	pcre_get_substring(sig, ov, MAX_SUBSTRINGS, 1, &str_ptr);
	if (strlen(str_ptr)) {
		dt->offset = atoi(str_ptr);
	}

	pcre_get_substring(sig, ov, MAX_SUBSTRINGS, 2, &str_ptr);
	if (strlen(str_ptr)) {
		dt->len = atoi(str_ptr);
	}

	return 1;

error:
	return -1;
}
开发者ID:MofX,项目名称:suricata,代码行数:27,代码来源:detect-payloadlenfield.c


示例3: ccze_squid_cache_log_process

static char *
ccze_squid_cache_log_process (const char *str, int *offsets, int match)
{
  char *date, *other;

  pcre_get_substring (str, offsets, match, 1, (const char **)&date);
  pcre_get_substring (str, offsets, match, 3, (const char **)&other);

  ccze_addstr (CCZE_COLOR_DATE, date);
  ccze_space();

  free (date);
  return other;
}
开发者ID:AsherBond,项目名称:ccze,代码行数:14,代码来源:mod_squid.c


示例4: DetectPrioritySetup

static int DetectPrioritySetup (DetectEngineCtx *de_ctx, Signature *s, char *rawstr)
{
    const char *prio_str = NULL;

#define MAX_SUBSTRINGS 30
    int ret = 0;
    int ov[MAX_SUBSTRINGS];

    ret = pcre_exec(regex, regex_study, rawstr, strlen(rawstr), 0, 0, ov, 30);
    if (ret < 0) {
        SCLogError(SC_ERR_PCRE_MATCH, "Invalid Priority in Signature "
                     "- %s", rawstr);
        return -1;
    }

    ret = pcre_get_substring((char *)rawstr, ov, 30, 1, &prio_str);
    if (ret < 0) {
        SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
        return -1;
    }

    /* if we have reached here, we have had a valid priority.  Assign it */
    s->prio = atoi(prio_str);

    return 0;
}
开发者ID:58698301,项目名称:suricata,代码行数:26,代码来源:detect-priority.c


示例5: extractHTTPClientHeaderVal

// < 0 for error.  >= 0 for len of extracted string
int extractHTTPClientHeaderVal(const u_int8_t *buf, u_int32_t size, int pcreidx, int substringnum, char *valuebuf, int valuelen) {
   int result;
   int ovector[9];
   int ovecsize = 9;
   const char *tmpstring;

//   printf("Searching for pcre %d (%s)\n", pcreidx, http_pcre_strings[pcreidx]);

   result = pcre_exec(http_pcre_structs[pcreidx].re, http_pcre_structs[pcreidx].pe,
                      (const char *)buf, size, 0, 0, ovector, ovecsize);

   if(result < 0 || result == PCRE_ERROR_NOMATCH) {
//      printf("pcre not found\n");
      return(-1); // We need to find the URL or this isn't a valid request
   }

   if(valuebuf) {
      result = pcre_get_substring((const char *)buf, ovector, result, substringnum, &tmpstring);
      if(result < 0) {
//         printf("unable to extract substring\n");
         return(-2);
      }

      strncpy(valuebuf, tmpstring, valuelen);
      valuebuf[valuelen-1] = '\0';

      pcre_free_substring(tmpstring);
      return(strlen(valuebuf));
   }

   return(0);
}
开发者ID:dddddrrrr,项目名称:Snort,代码行数:33,代码来源:rzb_http-client.c


示例6: pcre_exec

char *Regexp_Get_Substring_From_Buffer(pcre *regexp, char *buffer, int substring)
{
	char *file;
	int rc, ovector[30];
	char *viewstate;

	if (regexp == NULL)
		return NULL;

	if (buffer == NULL)
		return NULL;

	rc = pcre_exec(regexp, NULL, buffer, strlen(file), 0, 0, ovector, 30);
	if (rc != -1)
	{
		rc = pcre_get_substring(buffer, ovector, 30, substring, (const char **)&viewstate);
		if (rc != -1)
		{
			return viewstate;
		}
		else
			printf("Get_Regexp_From_File: could not get substring.\n");
	}
	else
		printf("Get_Regexp_From_File: regexp didnt match.\n");

	return NULL;
}
开发者ID:jogi1,项目名称:twm,代码行数:28,代码来源:regexp.c


示例7: pcre_get_substring

std::string Pattern::group (int groupNumber)
{
    const char * stringPtr;

    int rc = pcre_get_substring (
                 _subject.substr (_offset[0]).c_str(),
                 _ovector,
                 _count,
                 groupNumber,
                 &stringPtr);

    if (rc < 0) {
        switch (rc) {

            case PCRE_ERROR_NOSUBSTRING:
                throw std::out_of_range ("Invalid group reference.");

            case PCRE_ERROR_NOMEMORY:
                throw match_error ("Memory exhausted.");

            default:
                throw match_error ("Failed to get named substring.");
        }
    }

    std::string matchedStr (stringPtr);

    pcre_free_substring (stringPtr);

    return matchedStr;
}
开发者ID:max3903,项目名称:SFLphone,代码行数:31,代码来源:Pattern.cpp


示例8: nvmRegExpCoproTestPattern

static uint32_t nvmRegExpCoproTestPattern (uint16_t pattern_id, uint8_t *haystack, uint32_t haylen,
							uint32_t start_offset, nvmRegExpCoproInternalData *redata) {
	nvmRegExpCoproPattern *rcp;
	int ovector[OVECTSIZE], m  = 0, matchoffset = 0; //, matchlen = 0;
#ifdef COPRO_REGEXP_DEBUG
			const char *tmp;
#endif
	redata -> matched = 0;

	/* Do the actual search */
	if (pattern_id < redata -> patterns_no) {
		rcp = &(redata -> patterns[pattern_id]);
		redebug ("Looking for RegExp: \"%s\"\n", rcp -> pattern);
		m = pcre_exec (rcp -> re, rcp -> re_extra, (char*) haystack + start_offset, haylen, 0, 0, ovector, OVECTSIZE);
		if (m > 0) {
			(redata -> match).rcp = rcp;
			(redata -> match).offset = matchoffset = ovector[0];
			(redata -> match).len = ovector[1] - ovector[0];
			redata -> matched = 1;
#ifdef COPRO_REGEXP_DEBUG
			pcre_get_substring (haystack + start_offset, ovector, m, 0, &tmp);
			redebug ("RegExp match at offset %d, len = %d: \"%s\"\n", matchoffset, (redata -> match).len, tmp);
			pcre_free_substring (tmp);
#endif
		}
	} else {
		printf ("RegExp coprocessor: tried to use inexistent pattern: %u\n", pattern_id);
	}

	return (redata -> matched);
}
开发者ID:AshleyPeterson,项目名称:netbee-lite,代码行数:31,代码来源:regexp.c


示例9: pcre_compile

char *execute_regex(char *pattern, char *subject, int desired_match)
{
    pcre *re;
    const char *einfo;
    int eoffset;
    int stringcount = 0;
    int ovector[desired_match * 3];
    int match_len;
    const char *match;
    char *match_returned;
    re = pcre_compile(pattern, 0, &einfo, &eoffset, NULL);
    if (!re) {
	fprintf(stderr, "%s\n", einfo);
	return NULL;
    }

    stringcount = pcre_exec(re, NULL, subject, strlen(subject),
			    0, 0, ovector, 30);

    match_len = pcre_get_substring(subject, ovector,
				   stringcount, desired_match, &match);
    if (match_len <= 0) {

	return NULL;
    }

    match_returned = (char *) malloc(match_len);
    strncpy(match_returned, match, match_len);
    pcre_free_substring(match);
    return match_returned;

}
开发者ID:SilverTab,项目名称:cydec,代码行数:32,代码来源:ydec.c


示例10: get_einvoice_recipient

/** Funkcja pobiera pierwszy czlon adresu email - tytulowy adresat w tresci maila
@param email - adres email z którego pobrany zostanie człon adresu przed znakiem '@'
@param out_recipient - nazwa konta email pobrana z adresu - wartość zwracana przez funkcję
@retval 0 - ok
@retval -1 - bład wywołania funkcji pcre_compile
@retval -2 - bład wywołania funkcji pcre_exec
*/
long get_einvoice_recipient(char *email,char **out_recipient)
{
	pcre *rc			= NULL;
	long re 			= 0;
	const char *error		= NULL;
	int erroroffset			= 0;
	int ovector[6];
	long len			= 0;
	
	memset(ovector,0,6);
	rc=pcre_compile(EINVOICE_RECP_REGEXP,0,&error, &erroroffset,NULL);

	if(rc==NULL)
	{
		PRINT_DEBUG("LIBBMDMAILERR Error. Error=%i\n",-1);
		return -1;
	}
	
	re = pcre_exec(rc,NULL,email,(int)strlen(email),0,0,ovector,6);
	if(re<0)
	{
		PRINT_DEBUG("LIBBMDMAILERR Error. Error=%i\n",-2);
		return -2;
	}
	
	len=pcre_get_substring(email,ovector,re,1,(const char **)out_recipient);
	
	pcre_free(rc);
	rc=NULL;
	return 0;
}
开发者ID:unizeto,项目名称:bmd,代码行数:38,代码来源:libbmdmail.c


示例11: pcre_exec

/**
 * \brief This function is used to parse icmp_seq option passed via icmp_seq: keyword
 *
 * \param icmpseqstr Pointer to the user provided icmp_seq options
 *
 * \retval iseq pointer to DetectIcmpSeqData on success
 * \retval NULL on failure
 */
DetectIcmpSeqData *DetectIcmpSeqParse (char *icmpseqstr) {
    DetectIcmpSeqData *iseq = NULL;
    char *substr[3] = {NULL, NULL, NULL};
#define MAX_SUBSTRINGS 30
    int ret = 0, res = 0;
    int ov[MAX_SUBSTRINGS];
    int i;
    const char *str_ptr;

    ret = pcre_exec(parse_regex, parse_regex_study, icmpseqstr, strlen(icmpseqstr), 0, 0, ov, MAX_SUBSTRINGS);
    if (ret < 1 || ret > 4) {
        SCLogError(SC_ERR_PCRE_MATCH,"Parse error %s", icmpseqstr);
        goto error;
    }

    for (i = 1; i < ret; i++) {
        res = pcre_get_substring((char *)icmpseqstr, ov, MAX_SUBSTRINGS, i, &str_ptr);
        if (res < 0) {
            SCLogError(SC_ERR_PCRE_GET_SUBSTRING,"pcre_get_substring failed");
            goto error;
        }
        substr[i-1] = (char *)str_ptr;
    }

    iseq = SCMalloc(sizeof(DetectIcmpSeqData));
    if (iseq == NULL)
        goto error;

    iseq->seq = 0;

    if (substr[0] != NULL && strlen(substr[0]) != 0) {
        if (substr[2] == NULL) {
            SCLogError(SC_ERR_MISSING_QUOTE,"Missing quote in input");
            goto error;
        }
    } else {
        if (substr[2] != NULL) {
            SCLogError(SC_ERR_MISSING_QUOTE,"Missing quote in input");
            goto error;
        }
    }

    uint16_t seq = 0;
    ByteExtractStringUint16(&seq, 10, 0, substr[1]);
    iseq->seq = htons(seq);

    for (i = 0; i < 3; i++) {
        if (substr[i] != NULL) SCFree(substr[i]);
    }

    return iseq;

error:
    for (i = 0; i < 3; i++) {
        if (substr[i] != NULL) SCFree(substr[i]);
    }
    if (iseq != NULL) DetectIcmpSeqFree(iseq);
    return NULL;

}
开发者ID:58698301,项目名称:suricata,代码行数:68,代码来源:detect-icmp-seq.c


示例12: pcre_exec

/**
 * \brief This function is used to parse icmp_id option passed via icmp_id: keyword
 *
 * \param icmpidstr Pointer to the user provided icmp_id options
 *
 * \retval iid pointer to DetectIcmpIdData on success
 * \retval NULL on failure
 */
DetectIcmpIdData *DetectIcmpIdParse (char *icmpidstr) {
    DetectIcmpIdData *iid = NULL;
    char *substr[3] = {NULL, NULL, NULL};
#define MAX_SUBSTRINGS 30
    int ret = 0, res = 0;
    int ov[MAX_SUBSTRINGS];

    ret = pcre_exec(parse_regex, parse_regex_study, icmpidstr, strlen(icmpidstr), 0, 0, ov, MAX_SUBSTRINGS);
    if (ret < 1 || ret > 4) {
        SCLogError(SC_ERR_PCRE_MATCH, "Parse error %s", icmpidstr);
        goto error;
    }

    int i;
    const char *str_ptr;
    for (i = 1; i < ret; i++) {
        res = pcre_get_substring((char *)icmpidstr, ov, MAX_SUBSTRINGS, i, &str_ptr);
        if (res < 0) {
            SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
            goto error;
        }
        substr[i-1] = (char *)str_ptr;
    }

    iid = SCMalloc(sizeof(DetectIcmpIdData));
    if (iid == NULL)
        goto error;
    iid->id = 0;

    if (substr[0]!= NULL && strlen(substr[0]) != 0) {
        if (substr[2] == NULL) {
            SCLogError(SC_ERR_INVALID_ARGUMENT, "Missing close quote in input");
            goto error;
        }
    } else {
        if (substr[2] != NULL) {
            SCLogError(SC_ERR_INVALID_ARGUMENT, "Missing open quote in input");
            goto error;
        }
    }

    /** \todo can ByteExtractStringUint16 do this? */
    uint16_t id = 0;
    ByteExtractStringUint16(&id, 10, 0, substr[1]);
    iid->id = htons(id);

    for (i = 0; i < 3; i++) {
        if (substr[i] != NULL) SCFree(substr[i]);
    }
    return iid;

error:
    for (i = 0; i < 3; i++) {
        if (substr[i] != NULL) SCFree(substr[i]);
    }
    if (iid != NULL) DetectIcmpIdFree(iid);
    return NULL;

}
开发者ID:58698301,项目名称:suricata,代码行数:67,代码来源:detect-icmp-id.c


示例13: pcre_get_named_substring

int
pcre_get_named_substring(const pcre *code, const pcre_char *subject, int *ovector,
  int stringcount, const pcre_char *stringname, const pcre_char **stringptr)
{
int n = pcre_get_stringnumber(code, stringname);
if (n <= 0) return n;
return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:8,代码来源:pcre_get.c


示例14: pcre_get_named_substring

int
pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,
  int stringcount, const char *stringname, const char **stringptr)
{
int n = get_first_set(code, stringname, ovector);
if (n <= 0) return n;
return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
}
开发者ID:ALFIO,项目名称:mongo,代码行数:8,代码来源:pcre_get.c


示例15: regex_request_to_sub

/** Extract a subcapture value from the request
 *
 * @note This is the PCRE variant of the function.
 *
 * @param[in] ctx	To allocate subcapture buffer in.
 * @param[out] out	Where to write the subcapture string.
 * @param[in] request	to extract.
 * @param[in] num	Subcapture index (0 for entire match).
 * @return
 *	- 0 on success.
 *	- -1 on notfound.
 */
int regex_request_to_sub(TALLOC_CTX *ctx, char **out, REQUEST *request, uint32_t num)
{
	fr_regcapture_t	*rc;
	char const	*p;
	int		ret;

	rc = request_data_reference(request, request, REQUEST_DATA_REGEX);
	if (!rc) {
		RDEBUG4("No subcapture data found");
		*out = NULL;
		return 1;
	}

	ret = pcre_get_substring(rc->regmatch->subject,
				 (int *)rc->regmatch->match_data, (int)rc->regmatch->used, num, &p);
	switch (ret) {
	case PCRE_ERROR_NOMEMORY:
		MEM(NULL);
		/*
		 *	We can't really fall through, but GCC 7.3 is
		 *	too stupid to realise that we can never get
		 *	here despite _fr_exit_now being marked as
		 *	NEVER_RETURNS.
		 *
		 *	If we did anything else, compilers and static
		 *	analysis tools would probably complain about
		 *	code that could never be executed *sigh*.
		 */
		/* FALL-THROUGH */

	/*
	 *	Not finding a substring is fine
	 */
	case PCRE_ERROR_NOSUBSTRING:
		RDEBUG4("%i/%zu Not found", num + 1, rc->regmatch->used);
		*out = NULL;
		return -1;

	default:
		if (ret < 0) {
			*out = NULL;
			return -1;
		}

		talloc_set_type(p, char);
		p = talloc_steal(ctx, p);

		RDEBUG4("%i/%zu Found: %pV (%zu)", num + 1, rc->regmatch->used,
			fr_box_strvalue_buffer(p), talloc_array_length(p) - 1);

		memcpy(out, &p, sizeof(*out));
		break;
	}

	return 0;
}
开发者ID:FreeRADIUS,项目名称:freeradius-server,代码行数:68,代码来源:regex.c


示例16: pcre_exec

/**
 * \brief This function is used to parse IPV4 ip_id passed via keyword: "id"
 *
 * \param idstr Pointer to the user provided id option
 *
 * \retval id_d pointer to DetectSshVersionData on success
 * \retval NULL on failure
 */
DetectSshVersionData *DetectSshVersionParse (char *str)
{
    DetectSshVersionData *ssh = NULL;
	#define MAX_SUBSTRINGS 30
    int ret = 0, res = 0;
    int ov[MAX_SUBSTRINGS];

    ret = pcre_exec(parse_regex, parse_regex_study, str, strlen(str), 0, 0,
                    ov, MAX_SUBSTRINGS);

    if (ret < 1 || ret > 3) {
        SCLogError(SC_ERR_PCRE_MATCH, "invalid ssh.protoversion option");
        goto error;
    }

    if (ret > 1) {
        const char *str_ptr;
        res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 1, &str_ptr);
        if (res < 0) {
            SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
            goto error;
        }

        /* We have a correct id option */
        ssh = SCMalloc(sizeof(DetectSshVersionData));
        if (ssh == NULL)
            goto error;

        memset(ssh, 0x00, sizeof(DetectSshVersionData));

        /* If we expect a protocol version 2 or 1.99 (considered 2, we
         * will compare it with both strings) */
        if (strcmp("2_compat", str_ptr) == 0) {
            ssh->flags |= SSH_FLAG_PROTOVERSION_2_COMPAT;
            SCLogDebug("will look for ssh protocol version 2 (2, 2.0, 1.99 that's considered as 2");
            return ssh;
        }

        ssh->ver = (uint8_t *)SCStrdup((char*)str_ptr);
        if (ssh->ver == NULL) {
            goto error;
        }
        ssh->len = strlen((char *) ssh->ver);

        SCLogDebug("will look for ssh %s", ssh->ver);
    }

    return ssh;

error:
    if (ssh != NULL)
        DetectSshVersionFree(ssh);
    return NULL;

}
开发者ID:jerryma119,项目名称:suricata,代码行数:63,代码来源:detect-ssh-proto-version.c


示例17: parse_command

int
parse_command (const char *cmd, int len, int *argc, char ***args)
{
    const char *r_error;
    int r_error_offset;
    pcre *re;
    int rc;
    int r_ovector[OVECCOUNT];
    int i = 0;

    re = pcre_compile (
        "^(?P<command>[a-zA-Z\\-]+)(?:[ ]([^ ]+))*",
        0,
        &r_error,
        &r_error_offset,
        NULL);

    if (re == NULL) {
        printf("PCRE compilation failed at offset %d: %s\n", r_error_offset, r_error);
        return 1;
    }

    rc = pcre_exec (
        re,
        NULL,
        cmd,
        len,
        0,
        0,
        r_ovector,
        OVECCOUNT);

    if (rc < 0)
    {
        switch(rc)
        {
            case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
            /*
            Handle other special cases if you like
            */
            default: printf("Matching error %d\n", rc); break;
        }
        pcre_free(re);     /* Release memory used for the compiled pattern */
        return 1;
    }

    *argc = rc;
    *args = calloc(rc+1, sizeof(char *));
    for (i = 1; i < rc; ++i) {
        pcre_get_substring(cmd, r_ovector, rc, i, (const char **)&(*args)[i-1]);
    }

    pcre_free(re);     /* Release memory used for the compiled pattern */
    return 0;
}
开发者ID:argux,项目名称:argux,代码行数:55,代码来源:command.c


示例18: pcre_get_substring

DeprecatedString RegularExpression::cap(int n) const
{
    const pcre_char *substring = NULL;
    int substringLength = pcre_get_substring(reinterpret_cast<const uint16_t *>(d->lastMatchString.unicode()), d->lastMatchOffsets, d->lastMatchCount, n, &substring);
    if (substringLength > 0) {
       DeprecatedString capture(reinterpret_cast<const DeprecatedChar *>(substring), substringLength);
       pcre_free_substring(substring);
       return capture;
    }
    return DeprecatedString();
}
开发者ID:oroisec,项目名称:ios,代码行数:11,代码来源:RegularExpression.cpp


示例19: return

char *regexp_substring( char *msg, int *ovector, int stringcount,
                        int stringnum )
{
    char        *string;

    if( pcre_get_substring( msg, ovector, stringcount, stringnum, 
                            (const char **)&string ) < 0 ) {
        return( NULL );
    } else {
        return( string );
    }
}
开发者ID:Beirdo,项目名称:beirdobot,代码行数:12,代码来源:regexp.c


示例20: matcher_append

int matcher_append(char * str) {
    int str_sz = strlen(str), exec_res;
    int groups[60], max_group = 60;
    
    if (str_sz > MBUF) {
        return -1;
    }
  
    if (str_sz + buff_offset >= MBUF) {
        strcpy(buff, str);
        buff_offset = 0;
    } else {
        strcpy(buff + buff_offset, str);
    }
    //printf("matcher: appending [%s]\n\n\n", str);

    exec_res = pcre_exec(regex, regex_opti, buff, buff_offset + str_sz, last_match, 0, groups, max_group);
    if (exec_res == PCRE_ERROR_NOMATCH) {
        puts(buff);
    }
    /*switch(exec_res) {
        case PCRE_ERROR_NOMATCH      : printf("String did not match the pattern\n");        break;
        case PCRE_ERROR_NULL         : printf("Something was null\n");                      break;
        case PCRE_ERROR_BADOPTION    : printf("A bad option was passed\n");                 break;
        case PCRE_ERROR_BADMAGIC     : printf("Magic number bad (compiled re corrupt?)\n"); break;
        case PCRE_ERROR_UNKNOWN_NODE : printf("Something kooky in the compiled re\n");      break;
        case PCRE_ERROR_NOMEMORY     : printf("Ran out of memory\n");                       break;
        default                      : printf("Unknown error\n");                           break;
    }*/
    if (exec_res >= 0) {
        int c;
        const char * match;
        exec_res = exec_res ? exec_res : max_group / 3;
        for (c = 0; c < exec_res; c += 2) {
            //if (c == 0 || c % 3 == 0) continue;
            pcre_get_substring(buff/* + offset ?*/, groups, exec_res, c, &match);
            //printf("Match(%2d/%2d): (%2d,%2d): '%s'\n", c, exec_res-1, groups[c*2], groups[c*2+1], match);
            callback(match);
            pcre_free_substring(match);
            last_match = c * 2 + 1;
        }
    } else {
        last_match = buff_offset;
    }

    //puts(buff);
    //printf("matcher: buff [%s]\n\n", buff);
    buff_offset = (buff_offset + str_sz) - last_match;
    memmove(buff, buff + last_match, buff_offset);
    buff[buff_offset] = '\0';
    
    return 0;
}
开发者ID:poseidon4o,项目名称:system-c,代码行数:53,代码来源:matcher.c



注:本文中的pcre_get_substring函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pcre_study函数代码示例发布时间:2022-05-30
下一篇:
C++ pcre_fullinfo函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap