子串模式匹配 [英] Substring Pattern Matching
本文介绍了子串模式匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助!
我想知道如何匹配用户输入的字符串.
例如,如果用户输入:aabbaa,则表示匹配
否则,如果用户输入:aabaa则表示不匹配.
您可以提供一些想法或示例代码如何执行此操作.
I need help!
I want to know how to match the string input by the user.
Example if the user input: aabbaa then it was match
otherwise if the user input: aabaa then it was mismatch.
Can you give some idea or sample code how to do it.
推荐答案
请参阅我对问题的评论:它的格式不完整.但是,对于各种各样的问题,正则表达式可以提供全面的解决方案.请参阅:
http://en.wikipedia.org/wiki/Regular_expression [ http://www.regular-expressions.info/reference.html/ [ http://www.regular-expressions.info/refadv.html [ http://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Regular_expression [ ^ ].
您总能找到合适的正则表达式引擎.请参阅:
http://code.google.com/p/regen/ [ http://www.drdobbs.com/cpp/regular-expressions-in-c/184404797 [ ^ ],
http://freecode.com/projects/cpp_regex [ http://bit.ly/NqDGfC [ http://www.ultrapico.com/Expresso.htm [在MFC中使用正则表达式 [ 问题在于该问题不是严格制定的. :-(
—SA
Please see my comment to the question: it is not fully formulated. However, for a wide class of problems, Regular Expressions can provide a comprehensive solution. Please see:
http://en.wikipedia.org/wiki/Regular_expression[^],
http://www.regular-expressions.info/reference.html/[^],
http://www.regular-expressions.info/refadv.html[^],
http://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Regular_expression[^].
You can always find a suitable Regular Expression Engine. Please see:
http://code.google.com/p/regen/[^],
http://www.drdobbs.com/cpp/regular-expressions-in-c/184404797[^],
http://freecode.com/projects/cpp_regex[^].
To find more, try this: http://bit.ly/NqDGfC[^].
When you have an engine, using it for complex problems can be a whole art. Look for Expresso. This is a tool which is very helpful:
http://www.ultrapico.com/Expresso.htm[^].
Expresso also has a very good manual on using Regular Expressions.
Please see also this CodeProject article:
Using Regular Expressions in MFC[^].
As pastopristi correctly noted below, it could be even as simple as ''=='' operator ofstd::string
… :-)
The problem is that the problem is not strictly formulated. :-(
—SA
看看类std :: string或CString.您可以在互联网上找到很多样本
jkchan
http://cgmath.blogspot.com
Take a look at class std::string, or CString. You can find plenty of samples in internet
jkchan
http://cgmath.blogspot.com
这篇关于子串模式匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文