why the fr*ck doesn't this work
https://pastebin.com/hQx8YcbQ
>>61581162
can you please just post the strace or something so I don't have to compile and run this. also please use sprunge.us or ix.io or some other pastebin that make less prominent a display of aidsmenship
>>61581182
There is no stack trace
1. the regex compiles
2. the regex runs without error
3. the regex appears to be written correctlyregex_t tok_subspace;
// Supposed to match on any string of digits inside of brackets
if ((r = regcomp(&tok_subspace, "\\{\\d+\\}",REG_EXTENDED))){
// No errors
char errbuf[1024];
regerror(r, &tok_subspace, errbuf, sizeof(errbuf));
printf("tok_subspace error: %s\n", errbuf);
return 1;
}
match.rm_so = 0;
match.rm_eo = 0;
// Doesn't match for "{1}" or "123"
// No errors
int x = regexec(&tok_subspace,token_buff,1,&match,0);
>>61581182
>>61581280
It is just supposed to match digits between brackets ("{" and "}")
I have tried a bunch of different ways and tested them on regexr.com
>>61581280
of course the regex compiles, what regex lib evaluates itself before runtime thats a fucking lifelong legacy of a task to accomplish
what OS is this on, your regex has extra escapes looking for where I sit
>>61581375
I'm on ubuntu 14.04
The reasoning for that is because I'm escaping the "\" char so that the regex sees "\{" instead of "the special char denoted by { "
It works for this one, which matches on anything between whitespace:if ((r = regcomp(&tok_word, "(\\S+)",REG_EXTENDED))){
char errbuf[1024];
regerror(r, &tok_word, errbuf, sizeof(errbuf));
printf("tok_var error: %s\n", errbuf);
return 1;
}
>>61581434
if you're using perl-style regex {} is for occurences of the previous element, if there are no previous occurences nothing happens.
>>61581485
What do I have to do to escape the operator to get the literal char "{"?
I want to match on a string of digits between brackets
>>61581571
just use \{
>>61582153
doesn't work
>>61582158
\{\d+\}
>>61581162
>actually programming in C
kekek, meme'd
>>61582167
"invalid preceding regular expression"
and It compiled on -std=gnu++11 with an error, "unrecognized escape sequence"
>>61582199
It's actually C++ calling a library written in C you hmong
>>61582167
>>61582158
try (\\{\\d+\\})
>>61582290
>(\\{\\d+\\})
doesn't match on "123" or "{1}"
>>61582314
try and see if it's the brackets that are the problem or the matching numbers
>>61582455
This is still not working:
regex_t tok_subspace;
if ((r = regcomp(&tok_subspace, "\\d+",REG_EXTENDED))){
char errbuf[1024];
regerror(r, &tok_subspace, errbuf, sizeof(errbuf));
printf("tok_subspace error: %s\n", errbuf);
return 1;
}
//- Verified token_buff contains "{1}" and "123" (null terminated) with prints when this is run
//- match is a valid regmatch_t
int x = regexec(&tok_subspace,token_buff,1,&match,0);
std::cout << x << std::endl;
That's all the code that could effect this variable