[try Beta version]
Not logged in

 
String pattern matching expressions?

Aug 6, 2017 at 6:27am
I'm not sure what you call the below but I'm trying to understand where
to start learning about writing expressions to iterate through C++ strings.

How do I learn how to search strings with expressions like ("\\b(sub)([^ ]*)");
What do you call this?

Thanks

1
2
3
  std::string s ("this subject has a submarine as a subsequence");
  std::smatch m;
  std::regex e ("\\b(sub)([^ ]*)");   // matches words beginning by "sub" 
Aug 6, 2017 at 6:45am
I think you are looking for the term "regular expressions". It is actually being abbreviated as "regex" in the code snippet you show.
Aug 6, 2017 at 8:31am
Yes, but I'm specifically trying to learn all the symbols and parenthesies / asterix etc I need to use, and what they mean to write the expression.

I found this link which seems to be helping.

http://www.informit.com/articles/article.aspx?p=2079020
Aug 6, 2017 at 12:22pm
Yes, but I'm specifically trying to learn all the symbols and parenthesies / asterix etc I need to use, and what they mean to write the expression.
That's what you'll learn if you read about regular expressions.
Aug 6, 2017 at 1:40pm
Start with a simple, minimal, tutorial introduction. For example: https://www.regexone.com/

Then move on to a more elaborate tutorial. For example: http://www.regular-expressions.info/tutorialcnt.html

Read up on the standard C++ regex library. For example: http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c15339/A-TR1-Tutorial-Regular-Expressions.htm
Topic archived. No new replies allowed.