stefano cerbioni
unread,Apr 21, 2022, 12:37:51 PM4/21/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message as abuse
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pcre...@googlegroups.com
hi guys sorry for disturb i have a strign like this
[{"symbol":"BTCUSDT", ... etc
i want match BTCUSDT , i create this: symbol":"(.*?)" but in
regexpbuddy (with PCRE) work perfect but if i give at my script not
match
anyone have idea?? thanks
my code
// -----------------------------------------------------------------------------------
// ---------------------------- REGEXP IN PERL STYLE
---------------------------------
// -----------------------------------------------------------------------------------
if ( strcmp(StyleRgXp, "p") == 0) {
pcre *re;
const char *error;
int erroffset;
int ovector[OVECCOUNT];
int rc, i;
char *substring_start ;
//char src[] = "111 <title>Hello World</title> 222";
//char pattern[] = "<title>(.*)</title>";
// printf("String : %s/n", TesTsSubj);
// printf("Pattern: %s/n", PatterN);
re = pcre_compile(PatterN, 0, &error, &erroffset, NULL);
if (re == NULL) {
printf("PCRE compilation failed at offset %d: %s/n",
erroffset, error);
//return 1;
}
// MATCH FIRST OCCURRENCE
******************************************************************
rc = pcre_exec(re, NULL, TesTsSubj, strlen(TesTsSubj), 0, 0,
ovector, OVECCOUNT);
if (rc < 0) {
if (rc == PCRE_ERROR_NOMATCH) substring_start
=("Sorry, no match .../n"); //printf("Sorry, no match .../n");
else substring_start = ("Matching error %d/n");//
printf("Matching error %d/n", rc);
//free(re);
//return 1;
}
//printf("/nOK, has matched .../n/n");
for (i = 1; i < rc; i++) {
substring_start = ((char *)TesTsSubj) + ovector[2*i];
int substring_length = ovector[2*i+1] - ovector[2*i];
//printf("%2d: %.*s/n", i, substring_length, substring_start);
// printf("Pattern: %s/n", substring_start);
substring_start[substring_length] = '\0';
}
RING_API_RETSTRING(substring_start);
// free(re);
// ******************************************************************************************