lua 解析ffmpeg结构体时候用的正则表达式

local text="AVCodec ff_jpeg2000_decoder = {"
.."    .name           = \"j2k\",\n"
.."    .type           = AVMEDIA_TYPE_VIDEO,\n"
.."    .id             = CODEC_ID_JPEG2000,\n"
.."    .priv_data_size = sizeof(J2kDecoderContext),\n"
.."    .init           = j2kdec_init,\n"
.."    .close          = decode_end,\n"
.."    .decode         = decode_frame,\n"
.."    .capabilities = CODEC_CAP_EXPERIMENTAL,\n"
.."    .long_name = NULL_IF_CONFIG_SMALL(\"JPEG 2000\"),\n"
.."    .pix_fmts =\n"
.."        (const enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_RGB24, PIX_FMT_NONE}\n"
.."};\n";
local text2=""
.."    .name           = \"j2k\",\n"
.."    .type           = AVMEDIA_TYPE_VIDEO,\n"
.."    .id             = CODEC_ID_JPEG2000,\n"
.."    .priv_data_size = sizeof(J2kDecoderContext),\n"
.."    .init           = j2kdec_init,\n"
.."    .close          = decode_end,\n"
.."    .decode         = decode_frame,\n"
.."    .capabilities = CODEC_CAP_EXPERIMENTAL,\n"
.."    .long_name = NULL_IF_CONFIG_SMALL(\"JPEG 2000\"),\n"
.."    .pix_fmts =\n"
.."        (const enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_RGB24, \n\nPIX_FMT_NONE}\n";
local szreg= "(%.%s-[%w_]+%s-=%s-%s-[^%b{}]-%s-[,}])";
local szreg2="(%.%s-[%w_]+%s-=%s-%b()%s-%b{}%s-[,}])"
--"(%b()%s-%b{})-"
local szreg3="(%.%s-[%w_]+%s-=%s-".."(%s-[^%b{}]-)((%b()%s-%b{})-)" .."%s-[,}])";
for index,value in string.gmatch(text,szreg3) do
	print("index\t",index,"\tvalue",value);
end
local tmp="%.%s-[%w_]+%s-=[%s-[%s%w_%b{}\"%[%]%(%)]+]?[%s-[%w_%b()\"]+]?[,}]";
local tmp2="%.%s-[%w_]+%s-=[%s-[%s%w_\"%[%]%(%)]+[%b{}]-]?[%s-[%w_%b()\",}]+]?";
local tmp3="[%.%s-[%w_=]+]?[[%s-[%s%w_\"%[%]%(%)]+[%b{}]-]?[%s-[%w_%b()\"]+[,}]]?]-";
local tmp4="[%.%s-[%w_=]+]?[[%s-[%s%w_\"%[%]%(%)]+[%b{}]-]?[%b{}]?[%s-[%w_%b()\"]+[,}]]?]-";
local tmp5="(%.%s-[%w_]+%s-)=(%s-(%b()%s-%b{})([%w_()]+)%s-[,}])";
--[[for index,value in string.gmatch(text2,"([%.]?%s-[%w_%b()%b{}%[%]\"%s]+%s-)") do
	print("index\t",index,"\tvalue",value);
end]]--
local text3="#if( FF_API_OLD_METADATA2)||\n1\n"
.."    const AVMetadataConv *metadata_conv;\n"
.."#elif \nsssss\n"
.."#if (FF_API_OLD_METADATA2) \n"
.."#endif\n"
.."#elif \n"
.."#endif";
local text4=".name           = \"video4linux,v4l\","
print(string.sub(text4,string.find(text4,"%b\"\"")))

版权所有,未经允许不得擅自转载.

源自:http://blog.csdn.net/weinyzhou/article/details/7533187

posted @ 2012-05-03 22:45  weinyzhou  阅读(330)  评论(0编辑  收藏  举报