开发者

using a perl regex in c

what does this regex match?

How can I use this regex in C?

I am getting error if I do:

if 开发者_开发问答(regcomp(&reg, "/[^\\]\]/", REG_EXTENDED | REG_ICASE) != 0) 

error:

warning: unknown escape sequence '\]'

Thanks in advance.


I think you need to escape your backslashes:

from "/[^\\]\]/" to "/[^\\\\]\\]/"


It worked when I escaped the backslashes and removed /s from both ends.


I like perl , and I also like C/C++. To make the best of both, I wrote a github project to solve this issue.

please see: https://github.com/tlqtangok/perlcpp

a short example is here :

P_eval("$a=2;$a=$a**10;"); 
Int("a") ;   // a= 1024  


P_eval("@arr=(0..9);"; 
P_arr_Int_i("arr", 8 );  // => 8 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜