Text processing | SoloLearn: Learn to code for FREE!


Text processing

Hi clas, plese describe to me what is differences about boost.regex match, strcmp, ordinary if clause? All is related to string validation works.


2/26/2021 3:55:40 AM

Oliver Pasaribu

6 Answers

New Answer


Strcmp is used for string comparison, in which each character is compared with relative string in ASCII characters, its difference is shown as output if difference is 0 then string are equal


strcmp just compare string regexp is widest, and could perform pattern matching (not just a == b but a in b)


So basically the purpose is to manipulate string object or variable. So, bost.regex itself actually is a string function and combination of conditional if?


I don't know bost.regex nor even regex in C/C++ are implemented... but I use regular expressions in other languages (a language inside another language) so I couldn't say if bost.regex is a string function ^^ however, yes, regular expression are designed to work with string, with a bit more than just few 'if' statements ;)


So the purpose is just only simplification. This is similar with assert, or string replace, insert, erase, strcpy, strpbrk, find_first, etc? We do we need same functionality with many differents name? I am little bit confused except for cstring and string. But please tell me when we should use c++ string and when we should use cstring or c-style string?


no reg exp are not just string "functionality with other names"... reg exp are powerfull kind of pattern language to do advanced search in string ^^ wich one of each should be used belong to you, depending on what you want/need to achieve: reg exp are powerfull but could be oversized to just check string equality ;)