×
Namespaces

Variants
Actions

Archived:Open C/C++: 使用正则表达式的缓慢问题

From Nokia Developer Wiki
Jump to: navigation, search

Archived.png存档: 这篇文章是存档,因为考虑到今天它与第三方开发者建立商业解决方案不相关。

  • 详细描述

当使用regex.h的regcomp方法编译某个正则表达式时会出现慢的情况:

  regex_t preg;
char* str = "192.168.1.123";
char* pattern = "([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})";
 
int rc;
size_t nmatch = 5;
regmatch_t pmatch[5];
 
//the next line will take 30-60 seconds to evaluate
if (0 != (rc = regcomp(&preg, pattern, REG_EXTENDED )))
{
printf("Regular expression compiling failed");
int c = getchar();
return false;
}

解决方案 最新版本的Open C/C++插件修正了这一问题

This page was last modified on 17 October 2013, at 08:00.
202 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×