使用regex.h
库(在UNIX中可用)和返回的参数如下=
由&
分离咬的位置,距离Corona688的帖子通过了关于Unix Linux Forums。如果你不使用Unix,你必须找到并下载一个正则表达式库。
#include <stdio.h>
#include <regex.h>
int main(void)
{
regex_t reg;
const char *regex="([^=&?]+)=([^&]+)";
const char *str="http://127.0.0.1/privet/register?action=cancel&[email protected]";
regmatch_t matches[16];
regcomp(®, regex, REG_EXTENDED);
if(regexec(®, str, 16, matches, 0) == 0)
{
printf("regex /%s/ matched string '%s' at bytes %d-%d\n",
regex, str, matches[0].rm_so, matches[0].rm_eo);
}
else
printf("regex /%s/ does not match string '%s'\n", regex, str);
}
你应该*修改你的问题*并且使用到目前为止您尝试过的表达方式。 “我的正则表达式有什么问题?”肯定会得到比你问的更好的反馈,这从根本上归结为“为我编写正则表达式”。 – WhozCraig
@ WhozCraig ..感谢您的建议。我已经相应地更新了我的帖子。 – ap6491