简体   繁体   English

正则表达式用于比较(C)字符串中的特殊字符

[英]Regex for comparing special Characters in (C)Strings

I have an MFC project where I need to read and compare various configuration strings from (xml-)files. 我有一个MFC项目,需要在其中读取和比较(xml-)文件中的各种配置字符串。

The problem is that they could contain one or multiple special characters like STX, ETX, LF, CR ... and so on. 问题在于它们可能包含一个或多个特殊字符,例如STX,ETX,LF,CR ...等。

An idea is using regex. 一个想法是使用正则表达式。 I could simply write the full regex pattern in the files and compare them with a match function. 我可以简单地在文件中编写完整的正则表达式模式,然后将它们与match函数进行比较。

As I looked this up via google and msdn, there were two different(?) regex frameworks for MFC but I don't see any difference between them nor do I see if they can solve my problem, meaning handle special characters. 当我通过google和msdn进行查找时,有两个用于MFC的正则表达式框架,但它们之间没有任何区别,也看不出它们是否可以解决我的问题,意味着可以处理特殊字符。

Do any of you have an experience with those frameworks? 你们中的任何一个都对这些框架有经验吗? Can you recommend one or can you think of another solution for this problem? 您可以推荐一个解决方案,还是可以考虑另一种解决方案?

Many thanks in advance. 提前谢谢了。

I recommend std::regex or boost::regex over non standard alternatives. 我建议在非标准替代方案中使用std :: regex或boost :: regex。 Also, they are able to support special characters. 此外,他们还可以支持特殊字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM