本文介绍了实现一个独立的平台Glob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想尝试 glob(3) 或 glob -alike函数在C ++中。I'm trying to implement glob(3), or glob-alike function in C++.将目录内容读入一个 std :: vector< std :: string> 容器(让我们调用此函数 ListDirectory() ),所以我显然只需要stringmatching部分 - 我的问题:I already have a function that reads directory contents into an std::vector<std::string> container (let's call this function ListDirectory()), so I'd obviously only need the stringmatching part - My questions: 在实现它时应该遵循什么样的概念? / li> 是否有常见的问题? 使用fullblown的regexp库a 如果使用简单模式匹配更好,是否已经有可用的工作函数/库/类( scanf 和朋友)? What kind of concept should one follow when implementing it?Are there common gotchas one should keep in mind?Is it wise to use a fullblown regexp library (like PCRE), or rather simple pattern matching a la Lua?If using simple pattern matching is better, are there already working functions/libraries/classes available (what about scanf and friends)?推荐答案如果您正在搜索与平台无关的通配符库,例如,有 shwild 图书馆。If you are searching platform independent wildcard library,for example, there is shwild library.如果你正在检查模式匹配为自我教育目的,作为基本正则表达式通过回溯,我认为第一章 美丽的代码 说明很好。If you are examining pattern matching for self-educational purpose,as for basic regular expression by backtracking,I think chapter one ofBeautiful Codeillustrates well.当你在正规表达式将通配符转换为正则表达式或将正则表达式代码转换为通配符匹配器将不是一项艰巨的工作。When once you are at home in regular expression, probably convertingwildcard to regular expression, or converting regular expression code towildcard matcher, won't be a hard job.正则表达式由NFA,详细的解释将在中找到Russ Cox的网站。With regard to realistic regular expression by NFA,detailed explanations will be found inRuss Cox's web site.希望这有助于 这篇关于实现一个独立的平台Glob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-14 08:01